Skip to content

Instantly share code, notes, and snippets.

@tuxfight3r
Last active April 19, 2019 11:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tuxfight3r/9abe5b65814571d6fb706787fa35c121 to your computer and use it in GitHub Desktop.
Save tuxfight3r/9abe5b65814571d6fb706787fa35c121 to your computer and use it in GitHub Desktop.
EKS Tips & Tricks

Get logged in user name

aws sts get-caller-identity

EKS updated Kubeconfig

aws eks update-kubeconfig --name eksdemocluster

Get login token for dashboard from authenticator

aws-iam-authenticator -i eks-cluster-name-XXXXXXXXXX  token

Get login credentials for ECR

aws ecr get-login --no-include-email --region us-east-1

Create ECR Repository

aws ecr create-repository --repository-name test-mohan

Docker push for the repository

docker build -t test-mohan .
docker tag test-mohan:latest 068061778601.dkr.ecr.us-east-1.amazonaws.com/test-mohan:latest
docker push 068061XXXXXX.dkr.ecr.us-east-1.amazonaws.com/test-mohan:latest

EKS Info

https://docs.aws.amazon.com/eks/latest/userguide/getting-started.html#vpc-create
https://interactive.linuxacademy.com/diagrams/TheEKSManifest.html

create storage class

cat <<EOF | kubectl create -f -
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
   name: gp2-resize
provisioner: kubernetes.io/aws-ebs
parameters:
  type: gp2
allowVolumeExpansion: true
EOF

Make a PVC

cat <<EOF | kubectl create -f -
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: myclaim
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 6Gi
EOF

Attach to a pod

kind: Pod
apiVersion: v1
metadata:
  name: mypod
spec:
  containers:
    - name: myfrontend
      image: nginx
      volumeMounts:
      - mountPath: "/var/www/html"
        name: mypd
  volumes:
    - name: mypd
      persistentVolumeClaim:
        claimName: myclaim

Get the provisioned pvc size and patch it

$ kubectl get pvc myclaim -o=jsonpath="{.status.capacity.storage}" -n demo1
2Gi

$  kubectl patch pvc myclaim -p '{"spec": {"resources": {"requests": {"storage": "4Gi"}}}}' -n demo1
persistentvolumeclaim "myclaim" patched

$ kubectl get pvc myclaim -o=jsonpath="{.status.capacity.storage}" -n demo1
4Gi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment