EKS

nicolaw 28th January 2020 at 11:41am
AWS Kubernetes

https://kubernetes.io/docs/tutorials/kubernetes-basics/deploy-app/deploy-interactive/

https://dzone.com/articles/50-useful-kubernetes-tools

https://acloud.guru/course/kubernetes-deep-dive/learn

  • kubectl proxy
  • kubectl get - list resources
    • kubectl get nodes
    • kubectl get deployments
    • kubectl get pods
    • kubectl get services
  • kubectl describe - show detailed information about a resource
  • kubectl logs - print the logs from a container in a pod
  • kubectl exec - execute a command on a container in a pod

kubectl create deployment kubernetes-bootcamp --image=gcr.io/google-samples/kubernetes-bootcamp:v1

kubectl get pods -o go-template --template '{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}'

kubectl expose deployment/kubernetes-bootcamp --type="NodePort" --port 8080
kubectl describe services/kubernetes-bootcamp
kubectl get services/kubernetes-bootcamp -o go-template='{{(index .spec.ports 0).nodePort}}'

# Using labels.
kubectl get pods -l run=kubernetes-bootcamp
kubectl get services -l run=kubernetes-bootcamp
export POD_NAME=$(kubectl get pods -o go-template --template '{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}')
echo Name of the Pod: $POD_NAME
kubectl label pod $POD_NAME app=v1
kubectl describe pods $POD_NAME
kubectl get pods -l app=v1
kubectl delete service -l run=kubernetes-bootcamp
kubectl exec -ti $POD_NAME curl localhost:8080

AWS EKS

brew tap weaveworks/tap
brew install weaveworks/tap/eksctl
brew upgrade eksctl && brew link --overwrite eksctl
eksctl version
eksctl create cluster --name my-cluster --version 1.14 --fargate
eksctl utils describe-stacks --region=us-east-1 --cluster=my-cluster
eksctl utils update-cluster-logging --region=us-east-1 --cluster=my-cluster --enable-types all
eksctl create fargateprofile --cluster my-cluster --name my-profile --namespace my-namespace --labels my-key=my-value
aws eks create-fargate-profile --cli-input-json file://coredns.json
kubectl patch deployment coredns -n kube-system --type json -p='[{"op": "remove", "path": "/spec/template/metadata/annotations/eks.amazonaws.com~1compute-type"}]'
kubectl port-forward svc/kubernetes-dashboard -n kube-system 6443:443

Fargate EKS w/ALB

https://docs.aws.amazon.com/eks/latest/userguide/alb-ingress.html

Classic Load Balancers and Network Load Balancers are not supported on pods running on Fargate. For ingress, AWS recommend that you use the ALB Ingress Controller on Amazon EKS (minimum version v1.1.4).

EKS clusters configured with Fargate alone (no managed on unmanaged node groups) does not work with Classic Load Balancer. In order to resolve this;

  • Kubernetes service should be exposed to create Application Load Balancer. To do this, AWS ALB ingress controller should be configured on your cluster as pre-requisite.

OR (workaround)

  • A managed or unmanaged node group (in your EKS VPC) should be created with at least one EC2 worker node. Once done, EC2 worker node(s) will be InService under Classic Load Balancer and will act as a bridge between ELB and Fargate EC2 node. Below is command to create managed node group with SSH key pair:
$ eksctl create nodegroup --cluster nix-test --ssh-access --ssh-public-key=<existing-key-pair-name> --region=us-east-1

Related