This lab uses the Kubernetes kops installer, to initialize a private Kubernetes cluster, with a secure bastion host. The student is guided, through the use of an ssh agent, to carry an RSA Identity through to the bastion host; and thus facilitate access to the kubernetes master node, without having to replicate the original rsa key, from the Jump Box used to create the cluster. Lastly, the student is shown that stopping the secure bastion host then prevents any access to the kubernetes nodes, and also any deployments of workloads, or use of the `kubectl` command.
Learning Objectives
Successfully complete this lab by achieving the following learning objectives:
- Create a Cluster, With a Private Topology, and Secure the Bastion Host
- The script, k8s-create-ac.sh has been provided for this lab. Review the script with the cat command.
- Create the cluster config files by executing the lab-provided script. Review the cluster configuration.
- Initialize the cluster.
Note: This is not the bastion host created as a jump box. This is a new bastion host, created by kops that is inside the vpc, with the master and worker nodes.
- Using the RSA Key, SSH to the Bastion Host, and Attempt to Access the Master Node
- Use the ssh command provided during the cluster initialization to establish a terminal session on the secure bastion host.
- In the AWS Console, take note of the IP addresses provided to the secure bastion host.
- From the secure bastion host, attempt to access the Kubernetes Master with ssh.
- Using an SSH Agent, Connect to the Secure Bastion Host, and Attempt to Access the Master Node
- Using
eval
, check if an SSH agent is already running. - Add the private RSA key as an identity.
- Connect to the secure bastion host, and attempt to connect to the master node using the private IP address.
- Verify that you have successfully connected to the master node.
- Using
- From the Master Node, Interrogate the Configuration, and Run the kube-bench Utility
- Review the
kube-apiserver.manifest
file in the/etc/kubernetes/manifests
directory. - Review the kube config file.
- Install version
0.3.1
of thekube-bench
utility. - Execute a
kube-bench
run against the master node, and review the results.
- Review the
- Using an SSH Session, From the Secure Bastion Host, Execute kubectl Remotely
- Using an
ssh
session from the bastion host, run thekubectl get nodes
command on the master node. - From the bastion host, list all running pods, in all namespaces.
- From the bastion host, create a pod using the example
pod.yaml
file, in the course GitHub repository. - Verify that the pod was created successfully.
- Using an
- From the AWS Console, Stop the Secure Bastion Host
- In the AWS Console, navigate to the EC2 Dashboard, and view the running instances.
- Select the secure bastion host from the list, and use the Instance State menu to stop the instance.