Skip to content

Instantly share code, notes, and snippets.

@darksinge
Last active October 2, 2023 18:40
Show Gist options
  • Save darksinge/557dc2a292826a6bae76348984ceb3e7 to your computer and use it in GitHub Desktop.
Save darksinge/557dc2a292826a6bae76348984ceb3e7 to your computer and use it in GitHub Desktop.
Kubernetes Cheat Sheet (and minikube, docker, kubectl, eksctl, and AWS ECR)

Docker Commands

  • docker exect -it myimage /bin/bash
  • docker build --tag myimage:tag_name .
  • docker container attach myimage
  • docker run -itd --name <name> --network <network> --publish 80:8080 myimage:tag
  • docker image tag myimage myrepo/myimage:tag
  • docker image push myrepo/myimage:tag

Cheat Sheet for things related to Kubernetes development

Use local image with minikube

  1. minikube start
  2. eval $(minikube docker-env)
  3. docker build ...
  4. kubectl run myimage --image myimage:latest --image-pull-policy=Never
  5. kubectl get pods

Delete minikube cluster (get a fresh start)

  • minikube delete

Accessing K8s Dashboard in EKS

$ kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep eks-admin | awk '{print $1}')
$ kubectl port-forward svc/kubernetes-dashboard -n kube-system 6443:443

Update kubeconfig for eksctl

  • aws eks --region <region> update-kubeconfig --name <service_name>

Check the location and credentials that kubeclt knows about

  • kubectl config view

Authenticate Docker to an Amazon ECR Registry

aws ecr get-login-password --region <region> | docker login --usernmae AWS -- password-stdin <account_id>.dkr.ecr.<region>.amazonaws.com/myrepository

Managing Secrets

  • kubectl create secret <secret_name>

Sealed Secrets

$ echo -n sekure_value | kubectl create secret generic mysecret --dry-run --from-file=mysecret=/dev/stdin -o json > mysecret.json
$ kubeseal <mysecret.json >mysealedsecret.json
$ kubectl apply -f ./mysealedsecret.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment