K3s cluster build with Terraform and deployed on AWS EC2 instances.
The container-runtime used is Docker.
The cluster runs cloud-provider-aws which is an interface between a Kubernetes cluster and AWS service APIs. It will be responsible to spin some AWS resources up when need be, such as load balancers.
The cluster runs 2 microservices (ms-users, ms-payments) on port 8080.
The api routes are respectively:
- GET /api/users/1
- GET /api/payments/qwe
- k3s
- Helm
- AWS (EC2, Cloudfront, AutoscalingGroup)
- Docker
- Terraform
- Bash
- Go
cd infrastructure/regional
AWS_ACCESS_KEY_ID={your_access_key} AWS_SECRET_ACCESS_KEY={your_secret} ENV=prod REGION={your_region} ./_deploy.shIn AWS Console, edit the desired capacity of the master Autoscaling group to 1.
Ssh into the master node and run:
cat /etc/rancher/k3s/k3s.yamlSsh into the master node and run:
kubectl create secret docker-registry regcred --docker-server=940432861086.dkr.ecr.eu-west-2.amazonaws.com --docker-username=AWS --docker-password=$(aws ecr get-login-password --region eu-west-2)cd cluster
helm install --kubeconfig ./kubeconfig.yaml --debug -f ./aws-k3s/ms-users-values.yaml ms-users ./aws-k3scd cluster
helm install --kubeconfig ./kubeconfig.yaml --debug -f ./aws-k3s/ms-users-values.yaml ms-users ./aws-k3scd infrastructure/global
AWS_ACCESS_KEY_ID={your_access_key} AWS_SECRET_ACCESS_KEY={your_secret} ENV=prod REGION={your_region} ./_deploy.sh@Todo cleanup below
k3s check-config kubectl cluster-info kubectl get endpoints -A
kubectl --kubeconfig ./k3s/kubeconfig.yaml get nodes kubectl --kubeconfig ./k3s/kubeconfig.yaml apply -f ./k3s/app1.yaml kubectl --kubeconfig ./k3s/kubeconfig.yaml get pods
kubectl logs -l k8s-app=aws-cloud-controller-manager -n kube-system kubectl -n kube-system logs aws-cloud-controller-manager-5cfzk
kubectl replace --force -f ./k3s/app1.yaml
kubectl -n kube-system logs aws-cloud-controller-manager-kbjwb
sudo /usr/local/bin/ctr images ls
sudo /usr/local/bin/ctr containers list
sudo /usr/local/bin/crictl pull --creds AWS:$(aws ecr get-login-password --region eu-west-2) 940432861086.dkr.ecr.eu-west-2.amazonaws.com/app1:latest
kubectl create secret docker-registry regcred --docker-server=940432861086.dkr.ecr.eu-west-2.amazonaws.com --docker-username=AWS --docker-password=$(aws ecr get-login-password --region eu-west-2)
Cluster Access https://rancher.com/docs/k3s/latest/en/cluster-access/
Install Helm: https://gist.github.com/icebob/958b6aeb0703dc24f436ee8945f0794f https://rancher.com/docs/rancher/v2.0-v2.4/en/installation/resources/advanced/helm2/helm-init/
