The Kubernetes Yml file establishes the objects necessary for creating Kube Deployment, PODs and Service objects that include Docker containers.
The Kube Yml file in the author’s example follows and explanations are in parenthesis:
apiVersion: apps/v1beta1
kind: Deployment (including Deployment properties)
metadata:
name: tool-portal-pods
spec:
replicas: 1 (quantity of PODs generated as a replica set)
template:
metadata:
name: tool-portal-pods
labels:
app: tool-portal (can be referenced by Service Object)
spec:
containers:
- name: mongodb
image: registry.ng.bluemix.net/mj1pate/mongo:MongoDB
imagePullPolicy: Always
ports:
- containerPort: 27107 (matches port exposed by container)
- name: control
image: registry.ng.bluemix.net/mj1pate/control:Control
imagePullPolicy: Always
ports:
- containerPort: 8081 (matches port exposed by container)
- name: model
image: registry.ng.bluemix.net/mj1pate/model:Model
imagePullPolicy: Always
ports:
- containerPort: 80 (matches port exposed by container)
hostAliases: placed in each container’s /etc/hosts file
- ip: 169.61.42.14
hostnames:
- e.2a.3da9.ip4.static.sl-reverse.com
---
apiVersion: v1
kind: Service (serves as proxy for container external I/O)
metadata:
name: portal-service
labels:
app: tool-portal
spec:
type: NodePort (declared because a single node involved)
selector:
app: tool-portal match label of Deployment PODs
ports:
- name: model
protocol: TCP
port: 80 (local container port)
nodePort: 30000 (proxied external port)
- name: control
protocol: TCP
port: 8081 local container port
nodePort: 30100 proxied external port
The Yml file as described above presents a basic functional configuration to Kubectl, producing:
Deployment
- establish quantity of PODs in the replica set
- allows staging deployment upgrades and updates
Service
Establishes an publicly facing proxy for public external traffic