Skip to content

Instantly share code, notes, and snippets.

@DaddyMoe
Last active April 12, 2019 11:35
Show Gist options
  • Save DaddyMoe/430da8dc14eccad74906083ba9685b7f to your computer and use it in GitHub Desktop.
Save DaddyMoe/430da8dc14eccad74906083ba9685b7f to your computer and use it in GitHub Desktop.
Kubernetes Tools Commands for installation, reset and usage

Commands for kubernetes - DevOps

on macOS - minikube | kubectl | docker

Setup:

saml2aws login  #
saml2aws        # Opt: configure. To configure user details.
export AWS_PROFILE=<my_profile>  # Set default profile

Usage

minikube dashboard	# Kubernetes GUI
kubectl config set-context $(kubectl config current-context) --namespace=<my_namesapace> 	# To set your default namespace:

Logs

klf <my_pod> | kubectl logs -f <my_pod>

# Tail ALL PODs label name for a given app. Also changes color when pod name changes / restarts
stern -l app=<my_app_name> 

# Tail logs of PODs on a different name space
stern -l app=<my_app_name> -n <my_namespace_1>
stern -l app=<my_app_name> -n <my_namespace_2>

Namespaces

kubectl get namespaces | kubens
kubectl get nodes
kubectl get all		# Show all pods and services:

kubens <my_namesapace> # Activate namespace to "my_namesapace"

Pods

kubectl describe pod <my_namesapace>
kubectl get pods | kgp
kubectl get pod <my_pod_id>	#Get Pod details
kgp --show-labels	# Get pod names and labels
kgp --show-labels -n <my_namesapace>

Deployments

kubectl create deployment hello-node --image=<my_image>
kubectl get deployment # View the Deployment

Minikube

Setup

brew update &&  \
brew install kubectl && \
brew cask install docker minikube virtualbox

# add the Minikube executable to your path if not already sorted by brew
sudo mv minikube /usr/local/bin

# Confirm version
docker --version #Docker version 18.09.2, build 6247962
docker-compose --version	#docker-compose version 1.23.2, build 1110ad01
docker-machine --version	# docker-machine version 0.16.1, build cce350d7
minikube version		# minikube version: v1.0.0
kubectl version --client # Client Version: version.Info{Major:"1", Minor:"14", GitVersion:"v1.14.0", GitCommit:"641856db18352033a0d96dbc99153fa3b27298e5", GitTreeState:"clean", BuildDate:"2019-03-26T00:04:52Z", GoVersion:"go1.12.1", Compiler:"gc", Platform:"darwin/amd64"}

Un install | Reset everything

minikube stop;		-	delete this cluster
minikube delete; 	-	delete this cluster
sudo rm -rf ~/.minikube ~/.kube ~/.kub;
brew uninstall kubectl;
brew cask uninstall docker virtualbox minikube;

Usage

minikube start	-	minikube start

Getting Secrets

#Change into kube system for secrets
kubens kube-system

# List all secrets in ns
kubectl get secrets

# output secret to yaml 
kubectl get secrets <secret_name> -o yaml

Testing

 # What k8s cluster am I using
kubectl config current-context

# View the kubectl configuration:
kubectl config view

# View cluster events:
kubectl get events

# List all of the releases.
helm list
# Test conn
aws s3 ls

# Test AWS CLI version
ecs-cli --version

# Test Kubectl version
kubectl version

Ref:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment