Skip to content

Instantly share code, notes, and snippets.

@burlistic
Created April 26, 2024 13:58
Show Gist options
  • Save burlistic/8a7a9205339389be320a56022b3dd5a1 to your computer and use it in GitHub Desktop.
Save burlistic/8a7a9205339389be320a56022b3dd5a1 to your computer and use it in GitHub Desktop.
# Kubenetes (Minikube / Kubecli) and related Linux / VIM commands
#Linux / Command line
~ = return the terminal ?
Ctrl+C = cancel
## VI
i = insert text mode
esc + : + w + q = save and close file
## minikube
minikube start
minikube start --driver=virtualbox --no-vtx-check (for windows)
minikube stop
minikube status
minikube version
minikube node list
minikube ip
minikube delete
minikube addon list
minilube addon enable {name of addon}
minikube dashboard
minikube service web-service = display app in your web browser
minikube service web-service --url == outputs URL
## kubectl
kubectl config view
### Creating with config map
kubectl apply -f app-blue-with-cm.yaml
kubectl get servcies
kubectl describe service {name of service}
kubectl get namespaces
kubectl create namespace new-namespace-name
kubectl get csr
kubectl get deployments
kubectl get replicasets
kubectl get pods
kubectl describe pod {podname}
With the -L option to the kubectl get pods command, we add extra columns in the output to list Pods with their attached Label keys and their values. In the following example, we are listing Pods with the Label keys k8s-app and label2:
kubectl get pods -L k8s-app,label2
In the following example, we are selecting all the Pods that have the k8s-app Label key set to value web-dash:
kubectl get pods -l k8s-app=web-dash
kubectl delete deployments web-dash
### Deploying using CLI
kubectl create -f webserver.yaml
kubectl create deployment webserver --image=nginx:alpine --replicas=3 --port=80
Create a webserver-svc.yaml file with the following content:
apiVersion: v1
kind: Service
metadata:
name: web-service
labels:
app: nginx
spec:
type: NodePort
ports:
- port: 80
protocol: TCP
selector:
app: nginx
Using kubectl, create the Service:
kubectl create -f webserver-svc.yaml
Expose a Deployment with the kubectl expose command:
kubectl expose deployment webserver --name=web-service --type=NodePort
### Config maps
kubectl create configmap my-config \
--from-literal=key1=value1 \
--from-literal=key2=value2
kubectl get configmaps my-config -o yaml
__
kubectl create -f customer1-configmap.yaml
kubectl create configmap permission-config \
--from-file=<path/to/>permission-reset.properties
### Secrets
kubectl create secret generic my-password \
--from-literal=password=mysqlpassword
kubectl get secret my-password
kubectl describe secret my-password
echo mysqlpassword | base64
echo "bXlzcWxwYXNzd29yZAo=" | base64 --decode
kubectl create -f mypass.yaml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment