PanChuan 2018.11.08
Kubernetes is an open-source system for automating deployment, scaling, and management of containerized applications
It groups containers that make up an application into logical units for easy management and discovery
Kubernetes is Greek for pilot or hemlsman (the person holding the ship's steering wheel)
2003
2013
2014
Microsoft/RedHat/IBM/Docker
https://blog.risingstack.com/the-history-of-kubernetes/
Container Runtime: Docker, rkt or else
apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2
kind: Deployment
metadata:
name: nginx-deployment
spec:
selector:
matchLabels:
app: nginx
replicas: 2 # tells deployment to run 2 pods matching the template
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.7.9
ports:
- containerPort: 80
sharing Linux namespace
apiVersion: v1
kind: Pod
metadata:
name: nginx
labels:
env: test
name: nginx
spec:
containers:
- image: docker-registery.itv.qiyi.domain/nginx:latest
name: nginx
ports:
- containerPort: 80
protocol: TCP
kubectl create -f ningx.yaml
- HTTP Get probe (check code status)
- TCP socket (check if can connect)
- Exec cmd (check ret status)
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-demo
spec:
replicas: 3
template:
metadata:
name: nginx-demo
labels:
app: nginx
env: test
spec:
containers:
- image: docker-registry.itv.qiyi.domain/nginx:latest
name: nginx-demo
apiVersion: v1
kind: Service
metadata:
name: nginx
spec:
ports:
- port: 80
targetPort: 8080
selector:
app: nginx
kubectl get svc
epginfo.product.svc.cluster.lcoal
NodePort :
=======
apiVersion: v1
kind: Service
metadata:
name: kubia-nodeport
spec:
type: NodePort
ports:
- port: 80
targetPort: 8080
nodePort: 30123
selector:
app: kubia
Ingress controller: Nginx, Traefik, Kong, HAProxy
apiVersion: batch/v1
kind: Job
metadata:
name: batch-job
spec:
template:
metadata:
labels:
app: batch-job
spec:
restartPolicy: OnFailure
containers:
- name: main
image: luksa/batch-job
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: batch-job-every-fifteen-minutes
spec:
schedule: "0,15,30,45 * * * *" // Linux cron table syntax
jobTemplate:
spec:
template:
metadata:
labels:
app: periodic-batch-job
spec:
restartPolicy: OnFailure
containers:
- name: main
image: luksa/batch-job
....
- DNS server
- Dashboard
- CNI net plugin
- Heapster
any possible changes trigger the controller to recheck the desired vs. actual replica count and act accrodingly