A Terraform Wiz example forking to test out RKE2 on AWS Gov Cloud with Istio
Deploying Rancher RKE2 Kubernetes to AWS GovCloud with Istio involves several steps, including setting up your AWS environment, deploying RKE2, and configuring Istio for service mesh capabilities. Below is a high-level guide with key instructions and code snippets to achieve this.
- AWS GovCloud Account: Ensure you have access to AWS GovCloud.
- AWS CLI Configured: Set up AWS CLI with your GovCloud credentials.
- Terraform: For infrastructure automation.
- RKE2 CLI: Rancher's RKE2 CLI tool for Kubernetes deployment.
- Kubectl: Kubernetes command-line tool.
- Helm: Package manager for Kubernetes.
- Istioctl: CLI tool for managing Istio.
First, create a Terraform configuration to set up the required AWS infrastructure (saved as main.tf in this repo)
SSH into the EC2 instances created by Terraform and install RKE2.
sudo amazon-linux-extras enable selinux-ng
sudo yum install selinux-policy-targeted
curl -sfL https://get.rke2.io | sudo INSTALL_RKE2_VERSION='v1.30.2+rke2r1' INSTALL_RKE2_TYPE='server' INSTALL_RKE2_METHOD=rpm sh -
# This will not work with Amazon Linux 2 due to SE linux so the Rancher Guide is busted so use my workaround above: sudo curl -sfL https://get.rke2.io | sudo sh -
sudo systemctl enable rke2-server.service
sudo systemctl start rke2-server.service
# Install Kubectl on Amazon Linux 2
curl -O https://s3.us-west-2.amazonaws.com/amazon-eks/1.30.2/2024-07-12/bin/linux/amd64/kubectl
chmod +x ./kubectl
mkdir -p $HOME/bin && cp ./kubectl $HOME/bin/kubectl && export PATH=$HOME/bin:$PATH
echo 'export PATH=$HOME/bin:$PATH' >> ~/.bashrc
kubectl version --client
# Copy the kubeconfig to a location for kubectl to use
sudo cp /etc/rancher/rke2/rke2.yaml ~/.kube/config
sudo chmod 600 ~/.kube/config
sudo amazon-linux-extras enable selinux-ng
sudo yum install selinux-policy-targeted
curl -sfL https://get.rke2.io | sudo INSTALL_RKE2_VERSION='v1.30.2+rke2r1' INSTALL_RKE2_TYPE='agent' INSTALL_RKE2_METHOD=rpm sh -
# This will not work with Amazon Linux 2 due to SE linux so the Rancher Guide is busted so use my workaround above: sudo curl -sfL https://get.rke2.io | sudo sh -
sudo systemctl enable rke2-agent.service
sudo systemctl start rke2-agent.service
# Install Kubectl on Amazon Linux 2
curl -O https://s3.us-west-2.amazonaws.com/amazon-eks/1.30.2/2024-07-12/bin/linux/amd64/kubectl
chmod +x ./kubectl
mkdir -p $HOME/bin && cp ./kubectl $HOME/bin/kubectl && export PATH=$HOME/bin:$PATH
echo 'export PATH=$HOME/bin:$PATH' >> ~/.bashrc
kubectl version --client
# Modify the agent config file to point to the server
sudo mkdir -p /etc/rancher/rke2/
echo "server: https://<RKE2_SERVER_PRIVATE_IP>:9345" | sudo tee /etc/rancher/rke2/config.yaml
# Start the agent service
sudo systemctl restart rke2-agent.service
After setting up the RKE2 Kubernetes cluster, install Istio.
curl -L https://istio.io/downloadIstio | sh -
cd istio-*
export PATH=$PWD/bin:$PATH
istioctl install --set profile=demo -y
kubectl label namespace default istio-injection=enabled
Deploy a sample application (like Bookinfo) to test Istio's service mesh.
kubectl apply -f samples/bookinfo/platform/kube/bookinfo.yaml
kubectl apply -f samples/bookinfo/networking/bookinfo-gateway.yaml
Find the external IP of the Istio ingress gateway:
kubectl get svc istio-ingressgateway -n istio-system
Navigate to the external IP to access the application.