Skip to main content
Version: 4.0.x

Manage the Bastion Host

The create-and-manage-bastion-instance Jenkins job creates the bastion host, an Amazon EC2 instance that runs Amazon Linux 2023. For more information, see Deploy a bastion instance.

The job installs the operating system updates that are available when it creates the instance. After that, you must update the instance yourself. Running the job again does not update an existing instance.

Update the Operating System Packages​

Amazon Linux 2023 locks each instance to the package repository version of the AMI that it was launched from. A plain dnf upgrade command installs only updates from that repository version, so it does not install updates from newer repository versions. You must upgrade to the latest repository version.

  1. Connect to the bastion host with SSH, or with AWS Systems Manager Session Manager.

  2. Check for a newer repository version:

    sudo dnf check-release-update

    If the command shows no output, the instance already uses the latest repository version.

  3. Install all updates from the latest repository version:

    sudo dnf upgrade --releasever=latest -y
  4. Check whether the instance needs a restart. Updates to the kernel and to core libraries take effect only after a restart.

    sudo dnf needs-restarting -r

    If the output says that a reboot is required, restart the instance:

    sudo reboot

These commands update the operating system and the tools that are installed as packages, such as the AWS CLI and the MySQL and PostgreSQL clients. For more information, see Managing package and operating system updates in AL2023 in the Amazon Linux 2023 User Guide.

Update the Kubernetes Tools​

The kubectl, eksctl, helm, and aws-iam-authenticator tools are not installed as packages. The job installs the tool versions that match your CloudOps for Kubernetes release, and dnf does not update them.

After you upgrade CloudOps for Kubernetes, update the tools to the versions of the new release:

  1. In your branch of the cloud-ops-kubernetes Git repository, open the bootstrap/versions.sh file and find the values of these variables:

    • EKSCTL_VERSION
    • KUBERNETES_VERSION
    • HELM_3_VERSION
    • AWS_IAM_AUTH_VERSION
  2. Connect to the bastion host.

  3. Set the tool versions. Replace each <value> with the value from bootstrap/versions.sh. For KUBECTL_VERSION, add .0 to the KUBERNETES_VERSION value. For example, if KUBERNETES_VERSION is 1.36, use 1.36.0.

    EKSCTL_VERSION="<value>"
    KUBECTL_VERSION="<value>"
    HELM_3_VERSION="<value>"
    AWS_IAM_AUTH_VERSION="<value>"
  4. Download the tools to a temporary directory, and verify their checksums. Each sha256sum command must print OK. If a command fails or does not print OK, do not continue.

    tools_dir=$(mktemp -d)
    cd "${tools_dir}"

    curl -fsSLO "https://github.com/eksctl-io/eksctl/releases/download/v${EKSCTL_VERSION}/eksctl_Linux_amd64.tar.gz"
    curl -fsSLO "https://github.com/eksctl-io/eksctl/releases/download/v${EKSCTL_VERSION}/eksctl_checksums.txt"
    grep " eksctl_Linux_amd64.tar.gz$" eksctl_checksums.txt | sha256sum --check

    curl -fsSLO "https://dl.k8s.io/release/v${KUBECTL_VERSION}/bin/linux/amd64/kubectl"
    curl -fsSLO "https://dl.k8s.io/release/v${KUBECTL_VERSION}/bin/linux/amd64/kubectl.sha256"
    echo "$(cat kubectl.sha256) kubectl" | sha256sum --check

    curl -fsSLO "https://get.helm.sh/helm-v${HELM_3_VERSION}-linux-amd64.tar.gz"
    curl -fsSLO "https://get.helm.sh/helm-v${HELM_3_VERSION}-linux-amd64.tar.gz.sha256sum"
    sha256sum --check "helm-v${HELM_3_VERSION}-linux-amd64.tar.gz.sha256sum"

    curl -fsSLO "https://github.com/kubernetes-sigs/aws-iam-authenticator/releases/download/v${AWS_IAM_AUTH_VERSION}/aws-iam-authenticator_${AWS_IAM_AUTH_VERSION}_linux_amd64"
    curl -fsSLO "https://github.com/kubernetes-sigs/aws-iam-authenticator/releases/download/v${AWS_IAM_AUTH_VERSION}/authenticator_${AWS_IAM_AUTH_VERSION}_checksums.txt"
    grep " aws-iam-authenticator_${AWS_IAM_AUTH_VERSION}_linux_amd64$" "authenticator_${AWS_IAM_AUTH_VERSION}_checksums.txt" | sha256sum --check
  5. Install the tools, update the mapkubeapis Helm plugin, and remove the temporary directory:

    tar xzf eksctl_Linux_amd64.tar.gz eksctl
    tar xzf "helm-v${HELM_3_VERSION}-linux-amd64.tar.gz" --strip-components=1 linux-amd64/helm
    sudo install -m 755 eksctl kubectl helm /usr/local/bin/
    sudo install -m 755 "aws-iam-authenticator_${AWS_IAM_AUTH_VERSION}_linux_amd64" /usr/local/bin/aws-iam-authenticator
    sudo /usr/local/bin/helm plugin update mapkubeapis

    cd ~
    rm -rf "${tools_dir}"
  6. Confirm the installed versions:

    eksctl version
    kubectl version --client
    helm version
    aws-iam-authenticator version

Replace the Bastion Host​

Instead of updating the bastion host, you can replace it. The new instance gets the latest Amazon Linux 2023 Amazon Machine Image (AMI) and the tool versions of your CloudOps for Kubernetes branch.

caution

Replacing the bastion host deletes the instance and any files on it.

  1. Run the create-and-manage-bastion-instance Jenkins job with deleteBastionResources selected.
  2. Run the job again with deleteBastionResources cleared and the same other parameter values.