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.
-
Connect to the bastion host with SSH, or with AWS Systems Manager Session Manager.
-
Check for a newer repository version:
sudo dnf check-release-updateIf the command shows no output, the instance already uses the latest repository version.
-
Install all updates from the latest repository version:
sudo dnf upgrade --releasever=latest -y -
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 -rIf 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:
-
In your branch of the
cloud-ops-kubernetesGit repository, open thebootstrap/versions.shfile and find the values of these variables:EKSCTL_VERSIONKUBERNETES_VERSIONHELM_3_VERSIONAWS_IAM_AUTH_VERSION
-
Connect to the bastion host.
-
Set the tool versions. Replace each
<value>with the value frombootstrap/versions.sh. ForKUBECTL_VERSION, add.0to theKUBERNETES_VERSIONvalue. For example, ifKUBERNETES_VERSIONis1.35, use1.35.0.EKSCTL_VERSION="<value>"KUBECTL_VERSION="<value>"HELM_3_VERSION="<value>"AWS_IAM_AUTH_VERSION="<value>" -
Download the tools to a temporary directory, and verify their checksums. Each
sha256sumcommand must printOK. If a command fails or does not printOK, 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 --checkcurl -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 --checkcurl -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 -
Install the tools, update the
mapkubeapisHelm plugin, and remove the temporary directory:tar xzf eksctl_Linux_amd64.tar.gz eksctltar xzf "helm-v${HELM_3_VERSION}-linux-amd64.tar.gz" --strip-components=1 linux-amd64/helmsudo 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-authenticatorsudo /usr/local/bin/helm plugin update mapkubeapiscd ~rm -rf "${tools_dir}" -
Confirm the installed versions:
eksctl versionkubectl version --clienthelm versionaws-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.
Replacing the bastion host deletes the instance and any files on it.
- Run the
create-and-manage-bastion-instanceJenkins job withdeleteBastionResourcesselected. - Run the job again with
deleteBastionResourcescleared and the same other parameter values.