Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

Alias Services Config Maps

alias k=kubectl # Use shortcuts/aliases for kubectl kubectl get configmaps # Get all ConfigMaps
kubectl get services # Get all Services # Create ConfigMap from literal
Namespaces kubectl get svc
kubectl get svc -n dev
# Get all Services shortcuts
# Get all Services in specific namespace
kubectl create configmap my-config
--from-literal=A_VERSION=1.0
kubectl get namespaces # Get all Namespaces kubectl describe service kubernetes # Show the pod details # Create ConfigMap from a file (properties)
kubectl get ns # Get all Namespaces shortcuts kubectl get svc redis -o wide # Show Service details kubectl create configmap my-config --from-file=config.properties
kubectl create ns new # Create a new Namespace # Create a service with expose, type NodePort, save in yaml
kubectl delete ns new # Delete a Namespace kubectl expose deployment nginx --name=app-service
--target-port=8080 --type=NodePort --port=8080
Pods --dry-run=client -o yaml > svc.yaml Deployments
kubectl get pods # Get all Pods # Create a service, kind clusterip
kubectl get po # Get all Pods shortcut kubectl get deploy # Get all Deployments shortcut
kubectl create service clusterip redis --tcp=6379:6379
kubectl get po --all-namespaces # Get Pods in all namespaces kubectl get deployments # Get all Deployments
kubectl get pod nginx -o wide # Show more details of the Pod # Get all Deployments in default Namespace

Cheat
kubectl describe pod nginx # Show the Pod’s content kubectl get deployments --namespace=default
kubectl run nginx --image nginx # Create a Pod with nginx image # Create Deployment
kubectl create deployment nginx --image=nginx
# Create a Pod with nginx image with a specific version

Sheet
# Create Deployment with a 3 replicas
kubectl run nginx --image=nginx:1.19
kubectl create deployment nginx --image=nginx --replicas=3
# Create the yaml for a Pod # Scale Deployment to 5
kubectl run nginx --image=nginx --dry-run=client -o yaml > kubectl scale deployment nginx --replicas=5
pod.yaml Made by Edith Puclla
# Create the yaml for a Deployment
kubectl apply -f pod.yaml # Create the Pod using yaml file
kubectl get pod nginx -o yml # Get the yaml file of the pod
Volumes kubectl create deployment nginx --image=nginx
--dry-run=client -o yaml > nginx-deploy.yaml
kubectl edit pod nginx kubectl get pv # Get Persistent Volume # Create the Pod using yaml file
k logs nginx kubectl get pvc # Get Persistent Volume Claim kubectl apply -f nginx-deploy.yaml
# Change the image version of the Pod kubectl get pv,pvc # Get Persistent Volume and Claim
kubectl set image pod/nginx nginx=nginx:1.17
# Execute the simple shell on the Pod Rolling Update apiVersion: apps/v1 Kubernetes API version
kubectl exec -it nginx /bin/sh kind: Deployment Kind of object
# Set the status of the deployment metadata:
# Delete a pod
kubectl rollout status deployment/nginx labels: Data that allows the object
kubectl delete pod nginx app: nginx
# Check the history of the deployment to be uniquely identified of
name: nginx-deployment the deployment
Pod nginx yaml file -> kubectl rollout history deployment/nginx spec:
apiVersion: v1 Kubernetes API version # Undo the latest rollout of a deployment replicas: 1 Replicas
kind: Pod Kind of object kubectl rollout undo deploy nginx selector:
metadata: matchLabels: Labels
name: nginx-pod
namespace: default Data that allows the object to
Secrets app: myapp
template:
be uniquely identified # Create a secret from literal metadata:
labels:
app: myapp
kubectl create secret generic my-secret labels:
app: myapp
spec: --from-literal=DB_Host=mysql Pod specification
spec:
containers: # Create a secret from a file containers:
- name: nginx-image Object specification kubectl create secret generic my-secret - image: nginx
image: nginx --from-file=secret.properties name: nginx

You might also like