Class 1
Class 1
Class 1
====================
Install Docker
$ sudo apt update && apt -y install docker.io
Install kubectl
$ curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s
https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/
amd64/kubectl && chmod +x ./kubectl && sudo mv ./kubectl /usr/local/bin/kubectl
Install Minikube
$ curl -Lo minikube
https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 &&
chmod +x minikube && sudo mv minikube /usr/local/bin/
Start Minikube
$ apt install conntrack
$ minikube start --vm-driver=none
$ minikube status
=================================
filename.yml or filename.yaml
--- # comment
- key1: value
key1.1: value
key1.2: value
key2: value
- key3: value
key4: value
key4.1: value
$ kubectl get rc
$ kubectl scale --replicas=3 rc -l myname=adam
===============================
kind: ReplicaSet # Defines the object to be
ReplicaSet
apiVersion: apps/v1 # Replicaset is not available on
v1
metadata:
name: myrs
spec:
replicas: 2
selector:
matchExpressions: # these must match the labels
- {key: myname, operator: In, values: [adam, adamm, aadam]}
- {key: env, operator: NotIn, values: [production]}
template:
metadata:
name: testpod7
labels:
myname: adam
spec:
containers:
- name: c00
image: ubuntu
command: ["/bin/bash", "-c", "while true; do echo Hello-Adam; sleep 5 ;
done"]
====
class -1st july
============
kind: Deployment
apiVersion: apps/v1
metadata:
name: mydeployments
spec:
replicas: 2
selector: # tells the controller which pods to watch/belong to
matchLabels:
name: deployment
template:
metadata:
name: testpod8
labels:
name: deployment
spec:
containers:
- name: c00
image: ubuntu
command: ["/bin/bash", "-c", "while true; do echo Hello-Adam; sleep 5;
done"]
apiVersion: v1
kind: Pod
metadata:
name: myvolconfig
spec:
containers:
- name: c1
image: centos
command: ["/bin/bash", "-c", "while true; do echo Hello-Adam; sleep 5 ; done"]
volumeMounts:
- name: testconfigmap
mountPath: "/tmp/config" # the config files will be mounted as ReadOnly
by default here
volumes:
- name: testconfigmap
configMap:
name: mymap # this should match the config map name created in the first
step
items:
- key: sample.conf
path: sample.conf
---------------------------
apiVersion: v1
kind: Pod
metadata:
name: myenvconfig
spec:
containers:
- name: c1
image: centos
command: ["/bin/bash", "-c", "while true; do echo Hello-Adam; sleep 5 ; done"]
env:
- name: MYENV # env name in which value of the key is stored
valueFrom:
configMapKeyRef:
name: mymap # name of the config created
key: sample.conf
-----------------
apiVersion: v1
kind: Pod
metadata:
name: myvolsecret
spec:
containers:
- name: c1
image: centos
command: ["/bin/bash", "-c", "while true; do echo Hello-Adam; sleep 5 ; done"]
volumeMounts:
- name: testsecret
mountPath: "/tmp/mysecrets" # the secret files will be mounted as
ReadOnly by default here
volumes:
- name: testsecret
secret:
secretName: mysecret
==============================namespace
apiVersion: v1
kind: Namespace
metadata:
name: dev
labels:
name: dev
==============cpu2.yml
apiVersion: v1
kind: Pod
metadata:
name: default-cpu-demo-2
spec:
containers:
- name: default-cpu-demo-2-ctr
image: nginx
resources:
limits:
cpu: "1"
========================
apiVersion: v1
kind: Pod
metadata:
name: default-cpu-demo-3
spec:
containers:
- name: default-cpu-demo-3-ctr
image: nginx
resources:
requests:
cpu: "0.75"
====================
apiVersion: v1
kind: LimitRange
metadata:
name: mem-min-max-demo-lr
spec:
limits:
- max:
memory: 1Gi
min:
memory: 500Mi
type: Container
==========
apiVersion: v1
kind: Pod
metadata:
name: constraints-mem-demo
spec:
containers:
- name: constraints-mem-demo-ctr
image: nginx
resources:
limits:
memory: "800Mi"
requests:
memory: "600Mi"