diff --git a/charts/README.md b/charts/README.md index a603bb2..b9b24f7 100644 --- a/charts/README.md +++ b/charts/README.md @@ -7,6 +7,7 @@ * [Let's Encrypt](letsencrypt/README.md) * [NFS-Ganesha](nfs-ganesha/README.md) * [NFS Server Provisioner](nfs-server-provisioner/README.md) +* [Portworx BBQ](portworx-bbq/README.md) * [Rancher Cluster Template](rancher-cluster-templates/README.md) * [WordPress](wordpress/README.md) diff --git a/scripts/README.md b/scripts/README.md index 4334e49..f27ab74 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -2,24 +2,45 @@ ## Bash functions +### Instruqt + +Name | Source +----------------------------|------------------------------------- +`instruqt_wait_hoststartup` | [instruqt/host.sh](instruqt/host.sh) + +### K3s + +Name | Source +----------------------|----------------------------------------------------- +`k3s_copy_kubeconfig` | [k3s/cluster_lifecycle.sh](k3s/cluster_lifecycle.sh) +`k3s_create_cluster` | [k3s/cluster_lifecycle.sh](k3s/cluster_lifecycle.sh) + +### Kubernetes + +Name | Source +--------------------------------------|----------------------------------------------------------------------------- +`k8s_create_letsencryptclusterissuer` | [kubernetes/certificate_management.sh](kubernetes/certificate_management.sh) +`k8s_install_certmanager` | [kubernetes/certificate_management.sh](kubernetes/certificate_management.sh) +`k8s_wait_fornodesandpods` | [kubernetes/cluster_status.sh](kubernetes/cluster_status.sh) + +### Keycloak + +Name | Source +-----------------------|--------------------------------------------------------- +`keycloak_login` | [authentication/keycloak.sh](authentication/keycloak.sh) +`keycloak_create_user` | [authentication/keycloak.sh](authentication/keycloak.sh) +`keycloak_delete_user` | [authentication/keycloak.sh](authentication/keycloak.sh) + +### Linux + +Name | Source +-----------------------------|------------------------------- +`linux_create_fileAndLoopDevice` | [linux/disk.sh](linux/disk.sh) + +### Rancher + Name | Source ------------------------------------------------|----------------------------------------------------------------------------- -`instruqt_wait_hoststartup` | [instruqt/host.sh](instruqt/host.sh) -`k3s_copy_kubeconfig` | [k3s/cluster_lifecycle.sh](k3s/cluster_lifecycle.sh) -`k3s_create_cluster` | [k3s/cluster_lifecycle.sh](k3s/cluster_lifecycle.sh) -`k8s_create_letsencryptclusterissuer` | [kubernetes/certificate_management.sh](kubernetes/certificate_management.sh) -`k8s_install_certmanager` | [kubernetes/certificate_management.sh](kubernetes/certificate_management.sh) -`k8s_wait_fornodesandpods` | [kubernetes/cluster_status.sh](kubernetes/cluster_status.sh) -`keycloak_login` | [authentication/keycloak.sh](authentication/keycloak.sh) -`keycloak_create_user` | [authentication/keycloak.sh](authentication/keycloak.sh) -`keycloak_delete_user` | [authentication/keycloak.sh](authentication/keycloak.sh) -`observability_check_stackpack` | [observability/stackpack.sh](observability/stackpack.sh) -`observability_create_ingestion_api_key` | [observability/api_key.sh](observability/api_key.sh) -`observability_delete_ingestion_api_key` | [observability/api_key.sh](observability/api_key.sh) -`observability_delete_stackpack` | [observability/stackpack.sh](observability/stackpack.sh) -`observability_get_component_snapshot` | [observability/stql.sh](observability/stql.sh) -`observability_get_component_state` | [observability/stql.sh](observability/stql.sh) -`observability_install_cli` | [observability/cli.sh](observability/cli.sh) +-----------------------------------------------|------------------------------------------------------------- `rancher_create_apikey` | [rancher/user_actions.sh](rancher/user_actions.sh) `rancher_create_customcluster` | [rancher/cluster_actions.sh](rancher/cluster_actions.sh) `rancher_first_login` | [rancher/manager_lifecycle.sh](rancher/manager_lifecycle.sh) @@ -31,11 +52,29 @@ Name | Source `rancher_update_password` | [rancher/user_actions.sh](rancher/user_actions.sh) `rancher_update_serverurl` | [rancher/manager_settings.sh](rancher/manager_settings.sh) `rancher_wait_capiready` | [rancher/manager_lifecycle.sh](rancher/manager_lifecycle.sh) -`suselinux_install_git` | [suselinux/packages.sh](suselinux/packages.sh) -`suselinux_install_helm` | [suselinux/packages.sh](suselinux/packages.sh) -`suselinux_install_kubectl` | [suselinux/packages.sh](suselinux/packages.sh) -`suselinux_install_podman` | [suselinux/packages.sh](suselinux/packages.sh) -`suselinux_register_cloudguest` | [suselinux/registration.sh](suselinux/registration.sh) + +### SUSE Observability + +Name | Source +-----------------------------------------|--------------------------------------------------------- +`observability_check_stackpack` | [observability/stackpack.sh](observability/stackpack.sh) +`observability_create_ingestion_api_key` | [observability/api_key.sh](observability/api_key.sh) +`observability_delete_ingestion_api_key` | [observability/api_key.sh](observability/api_key.sh) +`observability_delete_stackpack` | [observability/stackpack.sh](observability/stackpack.sh) +`observability_get_component_snapshot` | [observability/stql.sh](observability/stql.sh) +`observability_get_component_state` | [observability/stql.sh](observability/stql.sh) +`observability_install_cli` | [observability/cli.sh](observability/cli.sh) + +### SUSE Linux (previously SLES, SLE Micro) + +Name | Source +--------------------------------|------------------------------------------------------- +`suselinux_install_git` | [suselinux/packages.sh](suselinux/packages.sh) +`suselinux_install_helm` | [suselinux/packages.sh](suselinux/packages.sh) +`suselinux_install_kubectl` | [suselinux/packages.sh](suselinux/packages.sh) +`suselinux_install_openiscsi` | [suselinux/packages.sh](suselinux/packages.sh) +`suselinux_install_podman` | [suselinux/packages.sh](suselinux/packages.sh) +`suselinux_register_cloudguest` | [suselinux/registration.sh](suselinux/registration.sh) ## Concrete examples diff --git a/scripts/k3s/cluster_lifecycle.sh b/scripts/k3s/cluster_lifecycle.sh index 04791a5..fb10dd5 100644 --- a/scripts/k3s/cluster_lifecycle.sh +++ b/scripts/k3s/cluster_lifecycle.sh @@ -11,7 +11,7 @@ k3s_create_cluster() { local version=$1 - echo "Create management cluster (K3s)..." + echo 'Create management cluster (K3s)...' curl -sfL https://get.k3s.io | INSTALL_K3S_CHANNEL="${version}" K3S_KUBECONFIG_MODE="644" sh - } diff --git a/scripts/kubernetes/certificate_management.sh b/scripts/kubernetes/certificate_management.sh index 05325a2..ec8bb86 100644 --- a/scripts/kubernetes/certificate_management.sh +++ b/scripts/kubernetes/certificate_management.sh @@ -11,7 +11,7 @@ k8s_install_certmanager() { local version=$1 - echo "Installing cert-manager..." + echo 'Installing cert-manager...' helm repo add jetstack https://charts.jetstack.io helm repo update kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/${version}/cert-manager.crds.yaml diff --git a/scripts/kubernetes/cluster_status.sh b/scripts/kubernetes/cluster_status.sh index 634c6de..1fa95ee 100644 --- a/scripts/kubernetes/cluster_status.sh +++ b/scripts/kubernetes/cluster_status.sh @@ -11,13 +11,13 @@ k8s_wait_fornodesandpods() { # checks nodes are ready while ! kubectl get nodes --no-headers 2>/dev/null | grep -q .; do - echo "Waiting for nodes to be available..." + echo 'Waiting for nodes to be available...' sleep 5 done while true; do NOT_READY_NODES=$(kubectl get nodes --no-headers 2>/dev/null | grep -v " Ready" | wc -l) if [ "$NOT_READY_NODES" -eq 0 ]; then - echo "All nodes are ready." + echo 'All nodes are ready.' break else sleep 5 @@ -26,13 +26,13 @@ k8s_wait_fornodesandpods() { # checks pods are completed or running while ! kubectl get pods --all-namespaces --no-headers 2>/dev/null | grep -q .; do - echo "Waiting for pods to be available..." + echo 'Waiting for pods to be available...' sleep 5 done while true; do NOT_READY_PODS=$(kubectl get pods --all-namespaces --field-selector=status.phase!=Running,status.phase!=Succeeded --no-headers 2>/dev/null | wc -l) if [ "$NOT_READY_PODS" -eq 0 ]; then - echo "All pods are in Running or Completed status." + echo 'All pods are in Running or Completed status.' break else sleep 5 diff --git a/scripts/linux/disk.sh b/scripts/linux/disk.sh new file mode 100644 index 0000000..b53eb10 --- /dev/null +++ b/scripts/linux/disk.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# Collection of functions to work with disks on Linux + +####################################### +# Create a file and binds it to a loop device +# Arguments: +# File name +# Size file (number of blocks) +# Look device +# Examples: +# linux_create_fileAndLoopDevice '/loop-file1' '10240' '/dev/loop1' +####################################### +linux_create_fileAndLoopDevice() { + local fileName=$1 + local sizeFile=$2 + local loopDevice=$3 + + echo "Creating local file ${fileName} and loop device ${fileName}..." + + # prepares the file for use with loopback device (creates a file filled with zero bytes) + dd if=/dev/zero of=${fileName} bs=1M count=${sizeFile} status=progress + + # binds the file to the loop device (enabling to work with the file as if it were a block device, like a physical disk) + losetup ${loopDevice} ${fileName} +} diff --git a/scripts/rancher/cluster_actions.sh b/scripts/rancher/cluster_actions.sh index 4f1e9cf..fd4374b 100644 --- a/scripts/rancher/cluster_actions.sh +++ b/scripts/rancher/cluster_actions.sh @@ -7,7 +7,7 @@ # rancher_list_clusters ####################################### rancher_list_clusters() { - echo "Listing clusters registered in Rancher..." + echo 'Listing clusters registered in Rancher...' kubectl get clusters.provisioning.cattle.io --all-namespaces -o jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}' } @@ -27,7 +27,7 @@ rancher_create_customcluster_nowait() { rancher_wait_capiready - echo "Creating downstream cluster in Rancher..." + echo 'Creating downstream cluster in Rancher...' cat </dev/null; do sleep 1; done sleep 10 } @@ -48,7 +48,7 @@ rancher_first_login() { local rancherUrl=$1 local newPassword=$2 - echo "Do first login on Rancher..." + echo 'Do first login on Rancher...' BOOTSTRAP_PASSWORD=$(kubectl get secret --namespace cattle-system bootstrap-secret -o go-template='{{.data.bootstrapPassword|base64decode}}{{ "\n" }}') echo "DEBUG BOOTSTRAP_PASSWORD=${BOOTSTRAP_PASSWORD}" rancher_login_withpassword $rancherUrl 'admin' $BOOTSTRAP_PASSWORD @@ -67,14 +67,14 @@ rancher_first_login() { rancher_wait_capiready() { while true; do status=$(kubectl get deployment capi-controller-manager -n cattle-provisioning-capi-system -o jsonpath='{.status.conditions[?(@.type=="Available")].status}' 2>/dev/null) - if [ "$status" == "True" ]; then - echo "Deployment capi-controller-manager is available" + if [ "$status" == 'True' ]; then + echo 'Deployment capi-controller-manager is available' break fi sleep 10 done - while [[ $(kubectl get endpoints capi-webhook-service -n cattle-provisioning-capi-system -o jsonpath='{.subsets}' 2>/dev/null) == "" ]]; do + while [[ $(kubectl get endpoints capi-webhook-service -n cattle-provisioning-capi-system -o jsonpath='{.subsets}' 2>/dev/null) == '' ]]; do sleep 10 done - echo "Service capi-webhook-service is ready" + echo 'Service capi-webhook-service is ready' } diff --git a/scripts/rancher/manager_settings.sh b/scripts/rancher/manager_settings.sh index 29de830..37c23a1 100644 --- a/scripts/rancher/manager_settings.sh +++ b/scripts/rancher/manager_settings.sh @@ -11,6 +11,6 @@ rancher_update_serverurl() { local rancherUrl=$1 - echo "Sets Rancher URL in settings..." + echo 'Sets Rancher URL in settings...' kubectl patch settings.management.cattle.io server-url --type='merge' --patch '{ "value": "'$rancherUrl'" }' } diff --git a/scripts/rancher/user_actions.sh b/scripts/rancher/user_actions.sh index 3dded56..623c43e 100644 --- a/scripts/rancher/user_actions.sh +++ b/scripts/rancher/user_actions.sh @@ -44,7 +44,7 @@ rancher_update_password() { local currentPassword=$3 local newPassword=$4 - echo "Updates Rancher user password..." + echo 'Updates Rancher user password...' curl -s -k -H "Authorization: Bearer $token" \ -H 'Content-Type: application/json' \ -X POST \ @@ -71,7 +71,7 @@ rancher_create_apikey() { local token=$2 local description=$3 - echo "Creates a Rancher API Key..." + echo 'Creates a Rancher API Key...' API_KEY_RESPONSE=$(curl -s -k "$rancherUrl/v3/tokens" \ -H 'Content-Type: application/json' \ -H "Authorization: Bearer $token" \ diff --git a/scripts/suselinux/packages.sh b/scripts/suselinux/packages.sh index 2f98fdb..fb46814 100644 --- a/scripts/suselinux/packages.sh +++ b/scripts/suselinux/packages.sh @@ -46,6 +46,19 @@ suselinux_install_git() { zypper install -y git } +####################################### +# Install open-iscsi on SUSE Linux +# Examples: +# suselinux_install_openiscsi +####################################### +suselinux_install_openiscsi() { + zypper --gpg-auto-import-keys -q refresh + zypper --gpg-auto-import-keys -q install -y open-iscsi + systemctl -q enable iscsid + systemctl start iscsid + modprobe iscsi_tcp +} + ####################################### # Install Podman on SUSE Linux # Examples: