Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
kubectl get daemonsets -n kube-system
kubectl describe daemonset kube-flannel-ds -n kube-system
echo “apiVersion: apps/v1
kind: DaemonSet
metadata:
name: chippy
labels:
daemon: “yup”
#!/bin/bash
#Status of pods where app=nginx
kubectl get pods -l app=nginx
#Give an nginx pod a label “test=sure”
kubectl label pod nginx-deployment-6fdbb596db-2s2tp test=sure
#Detailed description of pod with label “test=sure”
kubectl describe pod -l test=sure
@joshy91
joshy91 / k8RepControllerRepSet.sh
Created July 13, 2018 08:32
Replication Controller and Replica Set yamls
#!/bin/bash
#Replication Controller and Replica Set yamls
#A replication controller is a precusor to a deployment
echo “apiVersion: v1
kind: ReplicationController
metadata:
name: nginx
spec:
replicas: 3
#!/bin/bash
#Self Healing
#Nginx deployment yaml created in previous script
kubectl create -f nginx-deployment.yaml
#Check status of pods; including replicas
kubectl get pods
#Delete indicated pod within nginx deployment
#!/bin/bash
#Manually scaling an application through yaml and cml
#Nginx deployment yaml created in previous script
kubectl create -f nginx-deployment.yaml
#Detailed status of nginx deployment
kubectl describe deployment nginx-deployment
#Scale deployment to 3 replicas
@joshy91
joshy91 / k8ManualScale.sh
Created July 13, 2018 07:29
Manually scaling an application
#!/bin/bash
#Manually scaling an application (can also be done through yaml changes)
#Nginx deployment yaml created in previous script
kubectl create -f nginx-deployment.yaml
#Detailed status of nginx deployment
kubectl describe deployment nginx-deployment
#Scale deployment to 3 replicas
@joshy91
joshy91 / k8configMapTest.sh
Created July 13, 2018 07:12
Create configmap yaml to create env variables for pod
#!/bin/bash
#Create configmap yaml to create env variables for pod
echo “apiVersion: v1
kind: ConfigMap
metadata:
name: school-config
namespace: default
data:
STUDENT_NAME: “Joshua Davidson”
@joshy91
joshy91 / k8ConfigMap4YAML.sh
Created July 12, 2018 22:37
Configure YAML file using Config Map
#!/bin/bash
#How k8 configures application
#Create config map
kubectl create configmap my-map –from-literal=school=LinuxAcademy
#Check status of config map
kubectl get configmaps
#Detailed description of config map
@joshy91
joshy91 / k8UpdateRollback.sh
Created July 12, 2018 22:12
Deployments, Rolling Update, Rollback
#!/bin/bash
#Deployments, Rolling Update, Rollback
#Nginx deployment yaml
echo “apiVersion: apps/v1beta2
kind: Deployment
metadata:
name: nginx-deployment
namespace: default
spec:
#!/bin/bash
#Basic status checks in kubernetes
#Check status of cluster
kubectl get nodes
#Determine if memory is low on specified node
kubectl describe node joshy914.mylabserver.com | grep MemoryPressure
#Determine if disk space is low on specified node
kubectl describe node joshy914.mylabserver.com | grep DiskPressure