### Install and start firewalld Source: https://ranchermanager.docs.rancher.com/how-to-guides/advanced-user-guides/open-ports-with-firewalld Install firewalld v7.x or later and start it. This is a prerequisite for the port configuration commands. ```shell yum install firewalld systemctl start firewalld systemctl enable firewalld ``` -------------------------------- ### Install and start RKE2 server Source: https://ranchermanager.docs.rancher.com/how-to-guides/new-user-guides/kubernetes-cluster-setup/rke2-for-rancher Commands to install RKE2 and enable/start the server service. ```shell curl -sfL https://get.rke2.io | sh - systemctl enable rke2-server.service systemctl start rke2-server.service ``` -------------------------------- ### Example Output of Load Balancer Service Source: https://ranchermanager.docs.rancher.com/getting-started/installation-and-upgrade/install-upgrade-on-a-kubernetes-cluster/rancher-on-aks Example output from the kubectl get service command, showing the EXTERNAL-IP (40.31.180.83) that should be saved for DNS setup. ```shell NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE traefik LoadBalancer 10.0.116.18 40.31.180.83 80:31229/TCP,443:31050/TCP 67s ``` -------------------------------- ### Install rancher-csp-adapter with values.yaml Source: https://ranchermanager.docs.rancher.com/integrations-in-rancher/cloud-marketplace/aws-cloud-marketplace/install-adapter Installs the adapter using a values.yaml file. Requires the values.yaml from the previous example. ```bash helm install rancher-csp-adapter rancher-charts/rancher-csp-adapter -f values.yaml --version $CSP_ADAPTER_VERSION ``` -------------------------------- ### Example output of kubectl get nodes Source: https://ranchermanager.docs.rancher.com/how-to-guides/new-user-guides/kubernetes-cluster-setup/k3s-for-rancher Expected output showing two nodes with the master role after successful K3s setup. ```shell ubuntu@ip-172-31-60-194:~$ sudo k3s kubectl get nodes NAME STATUS ROLES AGE VERSION ip-172-31-60-194 Ready master 44m v1.17.2+k3s1 ip-172-31-63-88 Ready master 6m8s v1.17.2+k3s1 ``` -------------------------------- ### Install K3s server with external datastore Source: https://ranchermanager.docs.rancher.com/how-to-guides/new-user-guides/kubernetes-cluster-setup/k3s-for-rancher Run this command on the first Linux node to start the K3s server and connect it to the external datastore. Replace and with your values. The datastore endpoint can also be set via the environment variable $K3S_DATASTORE_ENDPOINT. ```shell curl -sfL https://get.k3s.io | INSTALL_K3S_VERSION= sh -s - server \ --datastore-endpoint="" ``` -------------------------------- ### Provision RKE2 Server Source: https://ranchermanager.docs.rancher.com/how-to-guides/new-user-guides/manage-clusters/create-kubernetes-persistent-storage/manage-persistent-storage/use-external-ceph-driver Installs and starts the RKE2 server, configures the bash environment, and displays the node token. The token is required for agent nodes to join. The output shows a redacted token. ```shell sudo su curl -sfL https://get.rke2.io | sh - systemctl enable --now rke2-server cat > /root/.bashrc << EOF export PATH=$PATH:/var/lib/rancher/rke2/bin/ export KUBECONFIG=/etc/rancher/rke2/rke2.yaml EOF cat /var/lib/rancher/rke2/server/node-token token: K10ca0c38d4ff90d8b80319ab34092e315a8b732622e6adf97bc9eb0536REDACTED::server:ec0308000b8a6b595da000efREDACTED ``` -------------------------------- ### Install RKE2 using install.sh with artifact path Source: https://ranchermanager.docs.rancher.com/getting-started/installation-and-upgrade/other-installation-methods/air-gapped-helm-cli-install/install-kubernetes Run the install script with the INSTALL_RKE2_ARTIFACT_PATH environment variable pointing to the directory containing the downloaded artifacts. Execute this on each server to install RKE2. ```shell INSTALL_RKE2_ARTIFACT_PATH=/tmp/rke2-artifacts sh install.sh ``` -------------------------------- ### Example output for cattle-controllers lease Source: https://ranchermanager.docs.rancher.com/troubleshooting/other-troubleshooting-tips/rancher-ha Example output from the `kubectl -n kube-system get lease cattle-controllers` command. It shows the lease name, the current leader (holderIdentity), and the age of the lease. ```shell NAME HOLDER AGE cattle-controllers rancher-dbc7ff869-gvg6k 6h10m ``` -------------------------------- ### values.yaml for rancher-csp-adapter Source: https://ranchermanager.docs.rancher.com/integrations-in-rancher/cloud-marketplace/aws-cloud-marketplace/install-adapter Example values.yaml for the CSP adapter. The account number must be a string (quoted) or installation fails. ```yaml aws: enabled: true accountNumber: "$MY_ACC_NUM" roleName: $MY_ROLE_NAME additionalTrustedCAs: true ``` -------------------------------- ### Example Output of Ingress Check Source: https://ranchermanager.docs.rancher.com/troubleshooting/other-troubleshooting-tips/rancher-ha Example output showing the ingress with the configured FQDN and addresses. ```shell NAME HOSTS ADDRESS PORTS AGE rancher rancher.yourdomain.com x.x.x.x,x.x.x.x,x.x.x.x 80, 443 2m ``` -------------------------------- ### Example output for kube-dns Source: https://ranchermanager.docs.rancher.com/troubleshooting/other-troubleshooting-tips/dns Example output when using kube-dns, showing a running kube-dns pod. ```shell NAME READY STATUS RESTARTS AGE kube-dns-5fd74c7488-h6f7n 3/3 Running 0 4m13s ``` -------------------------------- ### chartValues Example Source: https://ranchermanager.docs.rancher.com/reference-guides/cluster-configuration/rancher-server-configuration/rke2-cluster-configuration Shows how to specify values for system charts installed by RKE2. Use this field instead of HelmChartConfig via additionalManifest to avoid unexpected behavior. ```yaml chartValues: chart-name: key: value ``` -------------------------------- ### Install Rancher with Docker Source: https://ranchermanager.docs.rancher.com/getting-started/quick-start-guides/deploy-rancher-manager/equinix-metal Run this command from a shell connected to the Equinix Metal host to install Rancher. The container is started in detached mode with restart policy unless-stopped, exposes ports 80 and 443, and runs with privileged privileges. ```shell sudo docker run -d --restart=unless-stopped -p 80:80 -p 443:443 --privileged rancher/rancher ``` -------------------------------- ### Install Rancher with Helm Source: https://ranchermanager.docs.rancher.com/getting-started/quick-start-guides/deploy-rancher-manager/helm-cli Installs Rancher using Helm into the cattle-system namespace. Requires a domain name that forwards traffic to the Linux machine; a fake domain like .sslip.io is used for this tutorial. Use the --version flag to install a specific Rancher version; otherwise the latest is installed. Includes both Linux/macOS and Windows PowerShell variants. ```shell helm install rancher rancher-latest/rancher \ --namespace cattle-system \ --set hostname=.sslip.io \ --set replicas=1 \ --set bootstrapPassword= # Windows Powershell helm install rancher rancher-latest/rancher ` --namespace cattle-system ` --set hostname=.sslip.io ` --set replicas=1 ` --set bootstrapPassword= ``` -------------------------------- ### Air gap installation image reference Source: https://ranchermanager.docs.rancher.com/how-to-guides/advanced-user-guides/configure-layer-7-nginx-load-balancer Prepend your private registry URL to the server tag when running the installation command for an air gap installation. Replace with your actual registry domain and port. ```text /rancher/rancher:latest ``` -------------------------------- ### Example Output of Pod Check Source: https://ranchermanager.docs.rancher.com/troubleshooting/other-troubleshooting-tips/rancher-ha Example output showing three Rancher pods running with 1/1 readiness. ```shell NAME READY STATUS RESTARTS AGE IP NODE rancher-7dbd7875f7-n6t5t 1/1 Running 0 8m x.x.x.x x.x.x.x rancher-7dbd7875f7-qbj5k 1/1 Running 0 8m x.x.x.x x.x.x.x rancher-7dbd7875f7-qw7wb 1/1 Running 0 8m x.x.x.x x.x.x.x ``` -------------------------------- ### Install Rancher with private registry and system charts Source: https://ranchermanager.docs.rancher.com/getting-started/installation-and-upgrade/other-installation-methods/air-gapped-helm-cli-install/install-rancher-ha Install Rancher with a private registry. Create the cattle-system namespace, then install the Rancher chart with placeholders for version, hostname, registry, and system chart settings. ```plain kubectl create namespace cattle-system ``` ```plain helm install rancher ./rancher-.tgz \ --namespace cattle-system \ --set hostname= \ --set image.registry= \ --set ingress.tls.source=secret \ --set systemDefaultRegistry= \ # Set a default private registry to be used in Rancher --set useBundledSystemChart=true # Use the packaged Rancher system charts ``` -------------------------------- ### Example output for CoreDNS Source: https://ranchermanager.docs.rancher.com/troubleshooting/other-troubleshooting-tips/dns Example output when using CoreDNS, showing a running coredns pod. ```shell NAME READY STATUS RESTARTS AGE coredns-799dffd9c4-6jhlz 1/1 Running 0 76m ``` -------------------------------- ### Install kubectl via gcloud Source: https://ranchermanager.docs.rancher.com/getting-started/installation-and-upgrade/install-upgrade-on-a-kubernetes-cluster/rancher-on-gke Use the Google Cloud SDK to install the kubectl command-line tool. ```bash gcloud components install kubectl ``` -------------------------------- ### Install K3s server with INSTALL_K3S_SKIP_DOWNLOAD Source: https://ranchermanager.docs.rancher.com/getting-started/installation-and-upgrade/other-installation-methods/air-gapped-helm-cli-install/install-kubernetes Installs K3s on a server node in an air-gapped environment. Requires the K3s binary and install script to be placed on the node beforehand, and the INSTALL_K3S_VERSION environment variable must match the version used to obtain the airgap images tar. ```shell INSTALL_K3S_SKIP_DOWNLOAD=true INSTALL_K3S_VERSION= ./install.sh ``` -------------------------------- ### Install rancher-backup charts from local files Source: https://ranchermanager.docs.rancher.com/how-to-guides/new-user-guides/backup-restore-and-disaster-recovery/migrate-rancher-to-new-cluster Installs the rancher-backup charts from local .tgz files on an air-gapped host, using private registry image settings. ```bash helm install rancher-backup-crd ./rancher-backup-crd-.tgz -n cattle-resources-system --create-namespace helm install rancher-backup ./rancher-backup-.tgz -n cattle-resources-system --set image.repository=/rancher/backup-restore-operator --set global.kubectl.repository=/rancher/kubectl ``` -------------------------------- ### Expected kubectl Output Source: https://ranchermanager.docs.rancher.com/how-to-guides/advanced-user-guides/istio-setup-guide/set-up-istio-gateway Example output from the kubectl get gateway -A command, showing the bookinfo-gateway with an age of 64 minutes. ```shell NAME AGE bookinfo-gateway 64m ``` -------------------------------- ### Example output for DNS service Source: https://ranchermanager.docs.rancher.com/troubleshooting/other-troubleshooting-tips/dns Example output showing the kube-dns service with its cluster IP and ports. ```shell NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE service/kube-dns ClusterIP 10.43.0.10 53/UDP,53/TCP 4m13s ``` -------------------------------- ### Install iSCSI initiator tool on RHEL Source: https://ranchermanager.docs.rancher.com/how-to-guides/new-user-guides/manage-clusters/create-kubernetes-persistent-storage/manage-persistent-storage/install-iscsi-volumes Install the iscsi-initiator-utils package on RHEL nodes to resolve iSCSI connection failures. ```bash yum install iscsi-initiator-utils -y ``` -------------------------------- ### Download RKE2 artifacts for air-gapped install Source: https://ranchermanager.docs.rancher.com/getting-started/installation-and-upgrade/other-installation-methods/air-gapped-helm-cli-install/install-kubernetes Download the RKE2 install script, rke2, rke2-images, and sha256sum archives from the release and place them in /tmp/rke2-artifacts on each server. This prepares the artifacts needed for an air-gapped installation. ```shell mkdir /tmp/rke2-artifacts && cd /tmp/rke2-artifacts/ wget https://github.com/rancher/rke2/releases/download/v1.21.5%2Brke2r2/rke2-images.linux-amd64.tar.zst wget https://github.com/rancher/rke2/releases/download/v1.21.5%2Brke2r2/rke2.linux-amd64.tar.gz wget https://github.com/rancher/rke2/releases/download/v1.21.5%2Brke2r2/sha256sum-amd64.txt curl -sfL https://get.rke2.io --output install.sh ``` -------------------------------- ### Start and enable rke2-server service Source: https://ranchermanager.docs.rancher.com/getting-started/installation-and-upgrade/other-installation-methods/rancher-behind-an-http-proxy/install-kubernetes Start and enable the rke2-server service after creating the RKE2 configuration file on every node. Follow the RKE2 High Availability documentation for the configuration file. ```shell systemctl enable rke2-server.service systemctl start rke2-server.service ``` -------------------------------- ### RKE template example YAML with rancher_kubernetes_engine_config Source: https://ranchermanager.docs.rancher.com/reference-guides/rke1-template-example-yaml Use this YAML as a starting point for an RKE template in Rancher. It shows the required nesting under `rancher_kubernetes_engine_config` and includes commented-out options for network plugins and service settings. Note that `enable_cluster_alerting` and `enable_cluster_monitoring` are not enforced, so end users can override them. ```yaml # # Cluster Config # docker_root_dir: /var/lib/docker enable_cluster_alerting: false # This setting is not enforced. Clusters # created with this sample template # would have alerting turned off by default, # but end users could still turn alerting # on or off. enable_cluster_monitoring: true # This setting is not enforced. Clusters # created with this sample template # would have monitoring turned on # by default, but end users could still # turn monitoring on or off. enable_network_policy: false local_cluster_auth_endpoint: enabled: true # # Rancher Config # rancher_kubernetes_engine_config: # Your RKE template config goes here. addon_job_timeout: 30 authentication: strategy: x509 ignore_docker_version: true # # # Currently only nginx ingress provider is supported. # # To disable ingress controller, set `provider: none` # # To enable ingress on specific nodes, use the node_selector, eg: # provider: nginx # node_selector: # app: ingress # ingress: provider: nginx kubernetes_version: v1.15.3-rancher3-1 monitoring: provider: metrics-server # # If you are using calico on AWS # # network: # plugin: calico # calico_network_provider: # cloud_provider: aws # # # To specify flannel interface # # network: # plugin: flannel # flannel_network_provider: # iface: eth1 # # # To specify flannel interface for canal plugin # # network: # plugin: canal # canal_network_provider: # iface: eth1 # network: options: flannel_backend_type: vxlan plugin: canal # # services: # kube-api: # service_cluster_ip_range: 10.43.0.0/16 # kube-controller: # cluster_cidr: 10.42.0.0/16 # service_cluster_ip_range: 10.43.0.0/16 # kubelet: # cluster_domain: cluster.local # cluster_dns_server: 10.43.0.0/16 # services: etcd: backup_config: enabled: true interval_hours: 12 retention: 6 safe_timestamp: false creation: 12h extra_args: election-timeout: 5000 heartbeat-interval: 500 gid: 0 retention: 72h snapshot: false uid: 0 kube_api: always_pull_images: false pod_security_policy: false service_node_port_range: 30000-32767 ssh_agent_auth: false windows_prefered_cluster: false ``` -------------------------------- ### Install iSCSI initiator tool on Ubuntu/Debian Source: https://ranchermanager.docs.rancher.com/how-to-guides/new-user-guides/manage-clusters/create-kubernetes-persistent-storage/manage-persistent-storage/install-iscsi-volumes Install the open-iscsi package on Ubuntu/Debian nodes to resolve iSCSI connection failures. ```bash sudo apt install open-iscsi ``` -------------------------------- ### Provision RKE2 Agent Source: https://ranchermanager.docs.rancher.com/how-to-guides/new-user-guides/manage-clusters/create-kubernetes-persistent-storage/manage-persistent-storage/use-external-ceph-driver Configures and starts an RKE2 agent node. The config.yaml sets the server address and token. The agent is installed with INSTALL_RKE2_TYPE=agent and the service is enabled. ```shell mkdir -p /etc/rancher/rke2/ cat > /etc/rancher/rke2/config.yaml << EOF server: https://10.100.103.23:9345 token: K10ca0c38d4ff90d8b80319ab34092e315a8b732622e6adf97bc9eb0536REDACTED::server:ec0308000b8a6b595da000efREDACTED EOF curl -sfL https://get.rke2.io | INSTALL_RKE2_TYPE="agent" sh - systemctl enable --now rke2-agent.service ``` -------------------------------- ### Example output for kubedns nameserver check Source: https://ranchermanager.docs.rancher.com/troubleshooting/other-troubleshooting-tips/dns Example output from the command that checks upstream nameservers in the kubedns container. Shows the pod name, host IP, and the nameservers listed in /etc/resolv.conf. ```shell Pod kube-dns-667c7cb9dd-z4dsf on host x.x.x.x nameserver 1.1.1.1 nameserver 8.8.4.4 ``` -------------------------------- ### Install K3s agent with K3S_URL and K3S_TOKEN Source: https://ranchermanager.docs.rancher.com/getting-started/installation-and-upgrade/other-installation-methods/air-gapped-helm-cli-install/install-kubernetes Installs K3s on an agent node in an air-gapped environment. Requires the K3s binary and install script to be placed on the node beforehand, and the INSTALL_K3S_VERSION environment variable must match the version used to obtain the airgap images tar. The K3S_URL and K3S_TOKEN variables must point to the server node and its node-token. ```shell INSTALL_K3S_SKIP_DOWNLOAD=true INSTALL_K3S_VERSION= K3S_URL=https://:6443 K3S_TOKEN= ./install.sh ``` -------------------------------- ### Install Rancher with Helm behind an HTTP proxy Source: https://ranchermanager.docs.rancher.com/getting-started/installation-and-upgrade/other-installation-methods/rancher-behind-an-http-proxy/install-rancher Install Rancher behind an HTTP proxy. First add the Helm repository, then create the cattle-system namespace, then install Rancher with proxy and noProxy settings, and finally wait for the deployment to finish. ```shell helm repo add rancher-latest ``` ```shell kubectl create namespace cattle-system shellCopied! ``` ```shell helm upgrade --install rancher rancher-latest/rancher \ --namespace cattle-system \ --set hostname=rancher.example.com \ --set proxy=http://${proxy_host} \ --set noProxy=127.0.0.0/8\,10.0.0.0/8\,cattle-system.svc\,172.16.0.0/12\,192.168.0.0/16\,.svc\,.cluster.local ``` ```shell kubectl rollout status deployment -n cattle-system rancher shellCopied! ``` -------------------------------- ### machineSelectorConfig example with label selector Source: https://ranchermanager.docs.rancher.com/reference-guides/cluster-configuration/rancher-server-configuration/k3s-cluster-configuration YAML example showing how to apply configuration to nodes matching a label selector. The machineLabelSelector can include matchExpressions and matchLabels, or be omitted to apply globally. ```yaml machineSelectorConfig - config: config-key: config-value machineLabelSelector: matchExpressions: - key: example-key operator: string # Valid operators are In, NotIn, Exists and DoesNotExist. values: - example-value1 - example-value2 matchLabels: key1: value1 key2: value2 ``` -------------------------------- ### Example output of docker ps for nginx-proxy Source: https://ranchermanager.docs.rancher.com/troubleshooting/kubernetes-components/troubleshooting-nginx-proxy Example output showing the nginx-proxy container with status 'Up 3 hours' and image rancher/rke-tools:v0.1.15. ```shell docker ps -a -f=name=nginx-proxy CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES c3e933687c0e rancher/rke-tools:v0.1.15 "nginx-proxy CP_HO..." 3 hours ago Up 3 hours nginx-proxy ``` -------------------------------- ### Install cert-manager Source: https://ranchermanager.docs.rancher.com/getting-started/installation-and-upgrade/resources/upgrade-cert-manager Installs cert-manager by applying all rendered manifest files in the cert-manager directory to the cert-manager namespace. ```plain kubectl -n cert-manager apply -R -f ./cert-manager ``` -------------------------------- ### PEM Certificate Key Example Source: https://ranchermanager.docs.rancher.com/getting-started/installation-and-upgrade/other-installation-methods/rancher-on-a-single-node-with-docker/certificate-troubleshooting Example of a PEM certificate key file, showing the header, base64-encoded content, and footer. ```shell -----BEGIN RSA PRIVATE KEY----- MIIGVDCCBDygAwIBAgIJAMiIrEm29kRLMA0GCSqGSIb3DQEBCwUAMHkxCzAJBgNV ... more lines VWQqljhfacYPgp8KJUJENQ9h5hZ2nSCrI+W00Jcw4QcEdCI8HL5wmg== -----END RSA PRIVATE KEY----- ``` -------------------------------- ### Install cloud-provider-azure Helm chart Source: https://ranchermanager.docs.rancher.com/how-to-guides/new-user-guides/kubernetes-clusters-in-rancher-setup/set-up-cloud-providers/azure Install or upgrade the cloud-provider-azure Helm chart in the kube-system namespace using the custom values.yaml. This is the fourth step in the CLI installation. ```shell helm upgrade --install cloud-provider-azure azure-cloud-controller-manager/cloud-provider-azure -n kube-system --values values.yaml ``` -------------------------------- ### Example output for external DNS resolution Source: https://ranchermanager.docs.rancher.com/troubleshooting/other-troubleshooting-tips/dns Example output from the external DNS resolution check, showing the resolved addresses. ```shell Server: 10.43.0.10 Address 1: 10.43.0.10 kube-dns.kube-system.svc.cluster.local Name: www.google.com Address 1: 2a00:1450:4009:80b::2004 lhr35s04-in-x04.1e100.net Address 2: 216.58.211.100 ams15s32-in-f4.1e100.net pod "busybox" deleted ``` -------------------------------- ### Example output for internal DNS resolution Source: https://ranchermanager.docs.rancher.com/troubleshooting/other-troubleshooting-tips/dns Example output from the internal DNS resolution check, showing the resolved addresses. ```shell Server: 10.43.0.10 Address 1: 10.43.0.10 kube-dns.kube-system.svc.cluster.local Name: kubernetes.default Address 1: 10.43.0.1 kubernetes.default.svc.cluster.local pod "busybox" deleted ``` -------------------------------- ### Example Cluster Config File Snippet Source: https://ranchermanager.docs.rancher.com/reference-guides/cluster-configuration/rancher-server-configuration/k3s-cluster-configuration Full example of a Rancher K3s cluster configuration in YAML, showing the provisioning.cattle.io/v1 Cluster resource with rkeConfig, machinePools, machineSelectorConfig, and upgradeStrategy. ```yaml apiVersion: provisioning.cattle.io/v1 kind: Cluster spec: cloudCredentialSecretName: cattle-global-data:cc-fllv6 clusterAgentDeploymentCustomization: {} fleetAgentDeploymentCustomization: {} kubernetesVersion: v1.26.7+k3s1 localClusterAuthEndpoint: {} rkeConfig: additionalManifest: "" chartValues: {} etcd: snapshotRetention: 5 snapshotScheduleCron: 0 */5 * * * machineGlobalConfig: disable-apiserver: false disable-cloud-controller: false disable-controller-manager: false disable-etcd: false disable-kube-proxy: false disable-network-policy: false disable-scheduler: false etcd-expose-metrics: false kube-apiserver-arg: - audit-policy-file=/etc/rancher/k3s/user-audit-policy.yaml - audit-log-path=/etc/rancher/k3s/user-audit.logs profile: null secrets-encryption: false machinePools: - controlPlaneRole: true etcdRole: true machineConfigRef: kind: Amazonec2Config name: nc-test-pool1-pwl5h name: pool1 quantity: 1 unhealthyNodeTimeout: 0s workerRole: true machineSelectorConfig: - config: docker: false protect-kernel-defaults: false selinux: false machineSelectorFiles: - fileSources: - configMap: name: '' secret: name: audit-policy items: - key: audit-policy path: /etc/rancher/k3s/user-audit-policy.yaml machineLabelSelector: matchLabels: rke.cattle.io/control-plane-role: 'true' registries: {} upgradeStrategy: controlPlaneConcurrency: '1' controlPlaneDrainOptions: deleteEmptyDirData: true disableEviction: false enabled: false force: false gracePeriod: -1 ignoreDaemonSets: true ignoreErrors: false postDrainHooks: null preDrainHooks: null skipWaitForDeleteTimeoutSeconds: 0 timeout: 120 workerConcurrency: '1' workerDrainOptions: deleteEmptyDirData: true disableEviction: false enabled: false force: false gracePeriod: -1 ignoreDaemonSets: true ignoreErrors: false postDrainHooks: null preDrainHooks: null skipWaitForDeleteTimeoutSeconds: 0 timeout: 120 ``` -------------------------------- ### Install Rancher with Helm (default certificates) Source: https://ranchermanager.docs.rancher.com/getting-started/installation-and-upgrade/install-upgrade-on-a-kubernetes-cluster Installs Rancher with the default certificate option (Rancher-generated CA). Set `hostname` to the DNS name pointing to your load balancer and `bootstrapPassword` to a unique value for the `admin` user. Use the `--version` flag to install a specific Rancher version, e.g., `--version 2.7.0`. ```shell helm install rancher rancher-/rancher \ --namespace cattle-system \ --set hostname=rancher.my.org \ --set bootstrapPassword=admin ``` -------------------------------- ### Install RKE2 on every node Source: https://ranchermanager.docs.rancher.com/getting-started/installation-and-upgrade/other-installation-methods/rancher-behind-an-http-proxy/install-kubernetes Install RKE2 on every node using the installation script. Ensure the RKE2 version is supported by Rancher; replace v1.xx with the desired channel or version. ```shell curl -sfL https://get.rke2.io | INSTALL_RKE2_CHANNEL=v1.xx sh - ``` -------------------------------- ### Install Helm CLI Source: https://ranchermanager.docs.rancher.com/getting-started/installation-and-upgrade/other-installation-methods/rancher-behind-an-http-proxy/install-rancher Downloads and installs the Helm CLI on a host with kubeconfig access to the Kubernetes cluster. Requires sudo privileges. ```shell curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 chmod +x get_helm.sh sudo ./get_helm.sh ``` -------------------------------- ### Install rancher-csp-adapter with AWS settings Source: https://ranchermanager.docs.rancher.com/integrations-in-rancher/cloud-marketplace/aws-cloud-marketplace/install-adapter Installs the CSP adapter with required AWS settings. Replace $MY_ACC_NUM, $MY_ROLE_NAME, and $CSP_ADAPTER_VERSION with your values. Accounts using the EU/UK marketplace listing must add --set image.repository=rancher/rancher-csp-adapter-eu. ```bash helm install rancher-csp-adapter rancher-charts/rancher-csp-adapter --namespace cattle-csp-adapter-system --set aws.enabled=true --set aws.roleName=$MY_ROLE_NAME --set-string aws.accountNumber=$MY_ACC_NUM --set additionalTrustedCAs=true --version $CSP_ADAPTER_VERSION ``` -------------------------------- ### Install kube-prometheus-stack chart Source: https://ranchermanager.docs.rancher.com/integrations-in-rancher/monitoring-and-alerting Installs the kube-prometheus-stack chart into the cattle-monitoring-system namespace using the provided values.yaml. The --debug and --wait flags provide verbose output and wait for deployment completion. ```shell helm install kube-prometheus-stack prometheus-community/kube-prometheus-stack \ --namespace cattle-monitoring-system \ --create-namespace \ --debug \ --wait \ -f values.yaml ``` -------------------------------- ### Example output for kube-dns configmap Source: https://ranchermanager.docs.rancher.com/troubleshooting/other-troubleshooting-tips/dns Example output from the kube-dns configmap listing command. Shows the upstreamNameservers key with a JSON array of nameserver addresses. ```shell upstreamNameservers:["1.1.1.1"] ``` -------------------------------- ### PEM Certificate Example Source: https://ranchermanager.docs.rancher.com/getting-started/installation-and-upgrade/other-installation-methods/rancher-on-a-single-node-with-docker/certificate-troubleshooting Example of a PEM certificate file, showing the header, base64-encoded content, and footer. ```shell -----BEGIN CERTIFICATE----- MIIGVDCCBDygAwIBAgIJAMiIrEm29kRLMA0GCSqGSIb3DQEBCwUAMHkxCzAJBgNV ... more lines VWQqljhfacYPgp8KJUJENQ9h5hZ2nSCrI+W00Jcw4QcEdCI8HL5wmg== -----END CERTIFICATE----- ``` -------------------------------- ### Deploy Hello World Manifest with kubectl create Source: https://ranchermanager.docs.rancher.com/how-to-guides/new-user-guides/kubernetes-resources-setup/horizontal-pod-autoscaler/test-hpas-with-kubectl Command to deploy the hello-world manifest to the cluster. Replace with the path to the manifest file. ```shell # kubectl create -f ``` -------------------------------- ### Get current Rancher Helm values Source: https://ranchermanager.docs.rancher.com/getting-started/installation-and-upgrade/install-upgrade-on-a-kubernetes-cluster/upgrades Retrieves the current values from the installed Rancher Helm chart. The output shows an example value; there will be more values listed. Use this as the first step before upgrading. ```shell helm get values rancher -n cattle-system hostname: rancher.my.org ``` -------------------------------- ### Install cert-manager and prepare Rancher namespace Source: https://ranchermanager.docs.rancher.com/getting-started/quick-start-guides/deploy-rancher-manager/helm-cli Adds the Rancher chart repository, creates the cattle-system namespace, installs cert-manager CRDs and the cert-manager Helm chart. Includes both Linux/macOS and Windows PowerShell variants. Requires kubectl and helm installed on your local workstation. ```shell helm repo add rancher-latest https://releases.rancher.com/server-charts/latest kubectl create namespace cattle-system kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download//cert-manager.crds.yaml helm repo add jetstack https://charts.jetstack.io helm repo update helm install cert-manager jetstack/cert-manager \ --namespace cert-manager \ --create-namespace # Windows Powershell helm install cert-manager jetstack/cert-manager ` --namespace cert-manager ` --create-namespace ``` -------------------------------- ### kubectl get pods output for hello-world Source: https://ranchermanager.docs.rancher.com/how-to-guides/new-user-guides/kubernetes-resources-setup/horizontal-pod-autoscaler/test-hpas-with-kubectl Expected output from `kubectl get pods` showing the hello-world pod running with 1/1 ready and 0 restarts. ```plaintext NAME READY STATUS RESTARTS AGE hello-world-54764dfbf8-q6l82 1/1 Running 0 6h ``` -------------------------------- ### Install Rancher with Helm Source: https://ranchermanager.docs.rancher.com/how-to-guides/new-user-guides/backup-restore-and-disaster-recovery/migrate-rancher-to-new-cluster Installs Rancher with Helm on the new cluster. Use the same Helm version that was used on the first cluster and set the hostname to the same server URL from the original environment. ```bash helm install rancher rancher-latest/rancher \ --namespace cattle-system \ --set hostname= \ --version x.y.z ``` -------------------------------- ### Install Rancher alpha version with --devel Source: https://ranchermanager.docs.rancher.com/getting-started/installation-and-upgrade/install-upgrade-on-a-kubernetes-cluster Install an alpha version of Rancher. Helm requires the --devel option for alpha releases. ```shell helm install rancher rancher-alpha/rancher --devel ``` -------------------------------- ### Example output of nginx.conf Source: https://ranchermanager.docs.rancher.com/troubleshooting/kubernetes-components/troubleshooting-nginx-proxy Example output of the generated NGINX configuration, showing the upstream kube_apiserver with controlplane node IPs and the proxy server listening on port 6443. ```nginx error_log stderr notice; worker_processes auto; events { multi_accept on; use epoll; worker_connections 1024; } stream { upstream kube_apiserver { server ip_of_controlplane_node1:6443; server ip_of_controlplane_node2:6443; } server { listen 6443; proxy_pass kube_apiserver; proxy_timeout 30; proxy_connect_timeout 2s; } } ``` -------------------------------- ### Basic kubectl commands for managing HPAs Source: https://ranchermanager.docs.rancher.com/how-to-guides/new-user-guides/kubernetes-resources-setup/horizontal-pod-autoscaler/manage-hpas-with-kubectl Commands to create, view, and delete HPAs. Creating with a manifest uses 'kubectl create -f '. Creating without a manifest (only CPU) uses 'kubectl autoscale deployment hello-world --min=2 --max=5 --cpu-percent=50'. Viewing basic info uses 'kubectl get hpa hello-world', detailed info uses 'kubectl describe hpa hello-world', and deleting uses 'kubectl delete hpa hello-world'. ```bash kubectl create -f ``` ```bash kubectl autoscale deployment hello-world --min=2 --max=5 --cpu-percent=50 ``` ```bash kubectl get hpa hello-world ``` ```bash kubectl describe hpa hello-world ``` ```bash kubectl delete hpa hello-world ``` -------------------------------- ### Example output of kubectl get service traefik Source: https://ranchermanager.docs.rancher.com/getting-started/installation-and-upgrade/install-upgrade-on-a-kubernetes-cluster/rancher-on-gke Example output from the kubectl get service command. The EXTERNAL-IP column (40.31.180.83) is the load balancer address to save for accessing Rancher. ```shell NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE traefik LoadBalancer 10.0.116.18 40.31.180.83 80:31229/TCP,443:31050/TCP 27m ``` -------------------------------- ### Install rancher-backup charts Source: https://ranchermanager.docs.rancher.com/how-to-guides/new-user-guides/backup-restore-and-disaster-recovery/migrate-rancher-to-new-cluster Installs the rancher-backup CRD and rancher-backup charts into the cattle-resources-system namespace. Assumes outbound connectivity to Docker Hub. ```bash helm install rancher-backup-crd rancher-charts/rancher-backup-crd -n cattle-resources-system --create-namespace --version $CHART_VERSION helm install rancher-backup rancher-charts/rancher-backup -n cattle-resources-system --version $CHART_VERSION ``` -------------------------------- ### PKCS8 Private Key Example Source: https://ranchermanager.docs.rancher.com/getting-started/installation-and-upgrade/other-installation-methods/rancher-on-a-single-node-with-docker/certificate-troubleshooting Example of a PKCS8 private key file, which Rancher cannot read directly. If your key looks like this, convert it to PKCS1. ```shell -----BEGIN PRIVATE KEY----- MIIGVDCCBDygAwIBAgIJAMiIrEm29kRLMA0GCSqGSIb3DQEBCwUAMHkxCzAJBgNV ... more lines VWQqljhfacYPgp8KJUJENQ9h5hZ2nSCrI+W00Jcw4QcEdCI8HL5wmg== -----END PRIVATE KEY----- ``` -------------------------------- ### Get Load Balancer IP with kubectl Source: https://ranchermanager.docs.rancher.com/getting-started/installation-and-upgrade/install-upgrade-on-a-kubernetes-cluster/rancher-on-aks Run this command to get the address of the load balancer for the traefik service in the traefik namespace. The output shows the EXTERNAL-IP which should be saved for DNS setup. ```shell kubectl get service traefik --namespace=traefik ``` -------------------------------- ### machineGlobalConfig Example Source: https://ranchermanager.docs.rancher.com/reference-guides/cluster-configuration/rancher-server-configuration/rke2-cluster-configuration Shows how to specify RKE2 configurations that apply to every node. Options available in standalone RKE2 can be applied here. ```yaml machineGlobalConfig: etcd-arg: - key1=value1 - key2=value2 ``` -------------------------------- ### Example output of crictl ps for kube-proxy Source: https://ranchermanager.docs.rancher.com/troubleshooting/kubernetes-components/troubleshooting-worker-nodes-and-generic-components Example output from the 'crictl ps --name kube-proxy' command on RKE2, showing the kube-proxy container running. ```shell CONTAINER IMAGE CREATED STATE NAME ATTEMPT POD ID 26c7159abbcc rancher/hardened-kubernetes:v1.28.8-rke2r1-build20240404 3 hours ago Running kube-proxy 0 1a2b3c4d5e6f7 ``` -------------------------------- ### Get Ceph monitor details with ceph mon dump Source: https://ranchermanager.docs.rancher.com/how-to-guides/new-user-guides/manage-clusters/create-kubernetes-persistent-storage/manage-persistent-storage/use-external-ceph-driver Run this command on your SES cluster to get details about the Ceph monitor configuration. The output includes the fsid and mon addresses needed later for the ceph-csi driver installation. ```shell ceph mon dump ``` -------------------------------- ### Install new cert-manager version Source: https://ranchermanager.docs.rancher.com/getting-started/installation-and-upgrade/resources/upgrade-cert-manager Installs the new version of cert-manager using Helm. The command specifies the release name, chart, and namespace. ```bash helm install \ cert-manager jetstack/cert-manager \ --namespace cert-manager ``` -------------------------------- ### Example Cluster Config File Snippet Source: https://ranchermanager.docs.rancher.com/reference-guides/cluster-configuration/rancher-server-configuration/rke2-cluster-configuration A complete example of an RKE2 Cluster custom resource in YAML, showing typical fields like cloudCredentialSecretName, kubernetesVersion, rkeConfig with machinePools, machineSelectorConfig, and upgradeStrategy. ```yaml apiVersion: provisioning.cattle.io/v1 kind: Cluster spec: cloudCredentialSecretName: cattle-global-data:cc-s879v kubernetesVersion: v1.25.12+rke2r1 localClusterAuthEndpoint: {} rkeConfig: additionalManifest: "" chartValues: rke2-calico: {} etcd: snapshotRetention: 5 snapshotScheduleCron: 0 */5 * * * machineGlobalConfig: cni: calico disable-kube-proxy: false etcd-expose-metrics: false profile: null kube-apiserver-arg: - audit-policy-file=/etc/rancher/rke2/user-audit-policy.yaml - audit-log-path=/etc/rancher/rke2/user-audit.logs machinePools: - controlPlaneRole: true etcdRole: true machineConfigRef: kind: Amazonec2Config name: nc-test-pool1-pwl5h name: pool1 quantity: 1 unhealthyNodeTimeout: 0s workerRole: true machineSelectorConfig: - config: protect-kernel-defaults: false machineSelectorFiles: - fileSources: - configMap: name: '' secret: name: audit-policy items: - key: audit-policy path: /etc/rancher/rke2/user-audit-policy.yaml machineLabelSelector: matchLabels: rke.cattle.io/control-plane-role: 'true' registries: {} upgradeStrategy: controlPlaneConcurrency: "1" controlPlaneDrainOptions: deleteEmptyDirData: true enabled: true gracePeriod: -1 ignoreDaemonSets: true timeout: 120 workerConcurrency: "1" workerDrainOptions: deleteEmptyDirData: true enabled: true gracePeriod: -1 ignoreDaemonSets: true timeout: 120 ``` -------------------------------- ### Add new Helm chart repository for Rancher Source: https://ranchermanager.docs.rancher.com/getting-started/installation-and-upgrade/resources/choose-a-rancher-version Adds the Helm chart repository that you want to start installing Rancher from, replacing the removed one. ```shell helm repo add rancher- https://releases.rancher.com/server-charts/ ``` -------------------------------- ### Example output of crictl ps for controlplane containers Source: https://ranchermanager.docs.rancher.com/troubleshooting/kubernetes-components/troubleshooting-controlplane-nodes Example output from the crictl ps command showing the three controlplane containers in Running state. Use this to verify the expected output. ```text CONTAINER IMAGE CREATED STATE NAME ATTEMPT POD ID POD NAMESPACE deb8a96948594 138b1e685e151 11 days ago Running kube-controller-manager 0 0996426295dc5 kube-controller-manager kube-system f5abb4c7846e4 138b1e685e151 11 days ago Running kube-scheduler 0 80cd9f30af0be kube-scheduler kube-system ecd8a6991c22a 138b1e685e151 11 days ago Running kube-apiserver 0 58e042fabe78c kube-apiserver kube-system ``` -------------------------------- ### Install prometheus-adapter chart Source: https://ranchermanager.docs.rancher.com/how-to-guides/new-user-guides/kubernetes-resources-setup/horizontal-pod-autoscaler/manage-hpas-with-kubectl Installs the prometheus-adapter chart in the kube-system namespace, specifying the Prometheus URL and port. This enables HPA to use custom metrics from Prometheus. ```shell # helm install --name prometheus-adapter banzai-charts/prometheus-adapter --set prometheus.url="http://prometheus.mycompany.io",prometheus.port="80" --namespace kube-system ``` -------------------------------- ### Install AWS cloud controller manager on RKE via Helm Source: https://ranchermanager.docs.rancher.com/how-to-guides/new-user-guides/kubernetes-clusters-in-rancher-setup/set-up-cloud-providers/amazon For RKE clusters, add the Helm repository, create a values.yaml with the required RBAC rules and arguments, install the chart, verify the installation, and optionally check the rollout status. The cluster remains uninitialized until the cloud controller manager is deployed. ```shell helm repo add aws-cloud-controller-manager https://kubernetes.github.io/cloud-provider-aws helm repo update ``` ```yaml # values.yaml hostNetworking: true tolerations: - effect: NoSchedule key: node.cloudprovider.kubernetes.io/uninitialized value: 'true' - effect: NoSchedule value: 'true' key: node-role.kubernetes.io/controlplane nodeSelector: node-role.kubernetes.io/controlplane: 'true' args: - --configure-cloud-routes=false - --use-service-account-credentials=true - --v=2 - --cloud-provider=aws clusterRoleRules: - apiGroups: - "" resources: - events verbs: - create - patch - update - apiGroups: - "" resources: - nodes verbs: - '*' - apiGroups: - "" resources: - nodes/status verbs: - patch - apiGroups: - "" resources: - services verbs: - list - patch - update - watch - apiGroups: - "" resources: - services/status verbs: - list - patch - update - watch - apiGroups: - '' resources: - serviceaccounts verbs: - create - get - apiGroups: - "" resources: - persistentvolumes verbs: - get - list - update - watch - apiGroups: - "" resources: - endpoints verbs: - create - get - list - watch - update - apiGroups: - coordination.k8s.io resources: - leases verbs: - create - get - list - watch - update - apiGroups: - "" resources: - serviceaccounts/token verbs: - create ``` ```shell helm upgrade --install aws-cloud-controller-manager aws-cloud-controller-manager/aws-cloud-controller-manager --values values.yaml ``` ```shell helm status -n kube-system aws-cloud-controller-manager ``` ```shell kubectl rollout status daemonset -n kube-system aws-cloud-controller-manager ``` -------------------------------- ### chartValues Example Source: https://ranchermanager.docs.rancher.com/reference-guides/cluster-configuration/rancher-server-configuration/k3s-cluster-configuration Specify values for system charts installed by K3s. Use this field instead of additionalManifest for customizing system charts to avoid unexpected behavior. ```yaml chartValues: chart-name: key: value ``` -------------------------------- ### Configure gcloud CLI with gcloud init Source: https://ranchermanager.docs.rancher.com/getting-started/installation-and-upgrade/install-upgrade-on-a-kubernetes-cluster/rancher-on-gke Run gcloud init to set up default gcloud settings interactively. Use the --console-only flag when using SSH on a remote server to prevent the command from launching a browser. ```shell gcloud init ``` ```shell gcloud init --console-only ``` -------------------------------- ### Get node conditions with kubectl get nodes -o go-template Source: https://ranchermanager.docs.rancher.com/troubleshooting/other-troubleshooting-tips/kubernetes-resources Use to list node conditions. The first command shows all conditions for every node; the second filters for active conditions that could prevent normal operation. The example output shows a worker node with DiskPressure set to True. ```shell kubectl get nodes -o go-template='{{range .items}}{{$node := .}}{{range .status.conditions}}{{$node.metadata.name}}{{": "}}{{.type}}{{":"}}{{.status}}{{"\n"}}{{end}}{{end}}' ``` ```shell kubectl get nodes -o go-template='{{range .items}}{{$node := .}}{{range .status.conditions}}{{if ne .type "Ready"}}{{if eq .status "True"}}{{$node.metadata.name}}{{": "}}{{.type}}{{":"}}{{.status}}{{"\n"}}{{end}}{{else}}{{if ne .status "True"}}{{$node.metadata.name}}{{": "}}{{.type}}{{":"}}{{.status}}{{"\n"}}{{end}}{{end}}{{end}}{{end}}' ``` ```shell worker-0: DiskPressure:True ``` -------------------------------- ### Add SMS receiver name and URL Source: https://ranchermanager.docs.rancher.com/reference-guides/monitoring-v2-configuration/receivers Example name and URL for adding the SMS receiver. The name must match the receivers.name field in the ConfigMap, and ns-1 is replaced with the namespace where the rancher-alerting-drivers app is installed. ```yaml name: telegram-receiver-1 url http://rancher-alerting-drivers-sachet.ns-1.svc:9876/alert ``` -------------------------------- ### Example output of etcdctl member list Source: https://ranchermanager.docs.rancher.com/troubleshooting/kubernetes-components/troubleshooting-etcd-nodes Example output from the etcdctl member list command. It shows the member ID, status, name, peer URL, client URL, and whether the member is a learner. ```shell 1c42407486e854, started, cluster-node1-f289ac71, https://IP:2380, https://IP:2379, false 45c68c44c5a792c, started, cluster-node2-67e3cf6f, https://IP:2380, https://IP:2379, false 7c584f77c5180258, started, cluster-node3-e97600bc, https://IP:2380, https://IP:2379, false ``` -------------------------------- ### Get current Rancher Helm values for AWS Marketplace deployment Source: https://ranchermanager.docs.rancher.com/getting-started/installation-and-upgrade/install-upgrade-on-a-kubernetes-cluster/upgrades Retrieves the current values when the deployment name is 'rancher-stable', for example when deploying through the AWS Marketplace. Use this instead of the default 'rancher' deployment name. ```shell helm get values rancher-stable -n cattle-system hostname: rancher.my.org ``` -------------------------------- ### Install K3s with INSTALL_K3S_VERSION Source: https://ranchermanager.docs.rancher.com/getting-started/quick-start-guides/deploy-rancher-manager/helm-cli Installs a K3s cluster on a Linux machine with a specified Kubernetes version. Use the INSTALL_K3S_VERSION environment variable to set the version, and --cluster-init to enable embedded etcd for HA conversion capability. ```shell curl -sfL https://get.k3s.io | INSTALL_K3S_VERSION= sh -s - server --cluster-init ``` -------------------------------- ### Example metadata.yaml for CIS Benchmark Source: https://ranchermanager.docs.rancher.com/integrations-in-rancher/compliance-scans/configuration-reference Example metadata.yaml for a CIS benchmark. Use this to enrich XCCDF reports with custom metadata. The file is placed at the root of the custom benchmark directory and is read when generating XCCDF reports. ```yaml title: "My Custom CIS Benchmark" publisher: "My Organization" contributor: "My Team" creator: "My Team" description: "Custom CIS benchmark for foo clusters." platform: "cpe:/a:kubernetes:kubernetes" notice: "For internal use only." noticeId: "internal-notice" referenceHref: "https://example.com/benchmark" referenceTitle: "My Benchmark Reference" source: "https://example.com" ``` -------------------------------- ### Create resources with kubectl Source: https://ranchermanager.docs.rancher.com/how-to-guides/new-user-guides/kubernetes-clusters-in-rancher-setup/use-windows-clusters/azure-storageclass-configuration Use this command to create the resources defined in the manifest. Replace with the path to the file containing the ClusterRole and ClusterRoleBinding. ```shell # kubectl create -f ```