New Features of Kubernetes v1.2.0 beta

24
v1.2.0-beta.0 ~ Girag

Transcript of New Features of Kubernetes v1.2.0 beta

Page 1: New Features of Kubernetes v1.2.0 beta

v1.2.0-beta.0

~ Girag

Page 2: New Features of Kubernetes v1.2.0 beta

Outline

● released on March 7, 2016● improved scalability

○ more nodes○ more pods per node

● features from 1.1 time frames and stabilized ○ Horizontal pod auto-scaling API

■ add custom metrics○ Ingress API○ Job API○ DaemonSet API○ Deployment API○ ConfigMap API

○ Make it easier to create resources■ Namespace generation■ Secret/config generation■ export and convert

@girag

Page 3: New Features of Kubernetes v1.2.0 beta

● introduced in v1.1● part of extensions api● increase or decrease the pod’s count in replication controller /

deployments as per CPU utilization● implemented as control loop● uses heapster for metric collection (Currently CPU Utilization only)● autoscaling and rolling-update will not work together, if rolling-update

manipulates replica count of replication controller● will support custom metrics too

Horizontal Pod Autoscaler

@girag

Page 4: New Features of Kubernetes v1.2.0 beta

apiVersion: extensions/v1beta1kind: HorizontalPodAutoscalermetadata: name: tomcat7 namespace: defaultspec: scaleRef: kind: ReplicationController name: tomcat7 subresource: scale minReplicas: 1 maxReplicas: 5 cpuUtilization: targetPercentage: 80

Horizontal Pod Autoscaler

@girag

Page 5: New Features of Kubernetes v1.2.0 beta

apiVersion: extensions/v1beta1kind: HorizontalPodAutoscalermetadata: name: tomcat7 namespace: defaultspec: scaleRef: kind: ReplicationController name: tomcat7 subresource: scale minReplicas: 1 maxReplicas: 5 cpuUtilization: targetPercentage: 80

Horizontal Pod Autoscaler

@girag

HPA created with the name tomcat7 and act as service with 1-5 replications depending on load

if cpuUtilization > 80** and replica < 5 spawn tomcat7else cpuUtiliaztion fall down and sustained for 5 min and replica > 1 remove tomcat7

** when start or stop pods the metric get noises, so hpa wait for a while (3-5 minutes) after every action, for picking right data.

Page 6: New Features of Kubernetes v1.2.0 beta

● introduced in v1.1● part of extensions api● set of rules that allow inbound traffic to reach the k8s cluster services.● types

○ Single Service Ingress○ Simple Fanout○ Name based Virtual Hosting○ Loadbalancing

Ingress

@girag

Page 7: New Features of Kubernetes v1.2.0 beta

apiVersion: extensions/v1beta1kind: Ingressmetadata: name: virtual-hostingspec: rules: - host: api.gopaddle.io http: paths: - backend: serviceName: bm-gateway servicePort: 80

Ingress - host: beta.gopaddle.io http: paths: - backend: serviceName: bm-dashboard servicePort: 80

- host: doc.gopaddle.io http: paths: - backend: serviceName: bm-docs servicePort: 80

@girag

Page 8: New Features of Kubernetes v1.2.0 beta

Ingress - host: beta.gopaddle.io http: paths: - backend: serviceName: bm-dashboard servicePort: 80

- host: doc.gopaddle.io http: paths: - backend: serviceName: bm-docs servicePort: 80

@girag

bm-gateway

bm-dashboard

bm-docs

apiVersion: extensions/v1beta1kind: Ingressmetadata: name: virtual-hostingspec: rules: - host: api.gopaddle.io http: paths: - backend: serviceName: bm-gateway servicePort: 80

172.149.22.101

api beta doc

gopaddle.io

Page 9: New Features of Kubernetes v1.2.0 beta

● introduced in v1.1● part of extensions api● build custom lifecycle of pods● creates one or more pods and ensures that a specified number of them

successfully terminate● control lifecycle of pods which has RestartPolicy equal to OnFailure or Never.

Jobs

@girag

Page 10: New Features of Kubernetes v1.2.0 beta

apiVersion: extensions/v1beta1kind: Jobmetadata: name: appsvrspec: completions: 4 parallelism: 2 selector: matchLabels: app: appsvr template: metadata: name: appsvr labels: app: appsvr spec: containers: - name: appsvr image: bluemeric/javasvr restartPolicy: Never

Jobs

@girag

Page 11: New Features of Kubernetes v1.2.0 beta

apiVersion: extensions/v1beta1kind: Jobmetadata: name: appsvrspec: completions: 4 parallelism: 2 selector: matchLabels: app: appsvr template: metadata: name: appsvr labels: app: appsvr spec: containers: - name: appsvr image: bluemeric/javasvr restartPolicy: Never

Jobs

@girag

Job for appsvr, > .spec.completions : run 4 instance of appsvrs.> .spec.parallelism : run parallelly 2 appsvrs.

Page 12: New Features of Kubernetes v1.2.0 beta

● introduced in v1.1● part of extensions api● ensures that all nodes or some (by NodeSelector) runs pod● add a pod from Daemonset, while a node added in to k8s cluster, and

removes and clean pod when node goes off cluster.

Daemon Sets

@girag

Page 13: New Features of Kubernetes v1.2.0 beta

apiVersion: extensions/v1beta1kind: DaemonSetmetadata: name: ds-monitor labels:

apps: monitorspec: selector:

apps: monitor template:

metadata: name: d-monitor labels: apps: monitor spec: hostNetwork: true containers: - name: ds-mon image: bm/mon:v2

Daemon Sets

@girag

Page 14: New Features of Kubernetes v1.2.0 beta

apiVersion: extensions/v1beta1kind: DaemonSetmetadata: name: ds-monitor labels:

apps: monitorspec: selector:

apps: monitor template:

metadata: name: d-monitor labels: apps: monitor spec: hostNetwork: true containers: - name: ds-mon image: bm/mon:v2

Daemon Sets

@girag

node-01 node-02 node-03

kube-master

monitor monitor monitor

….

….

….

….

….

….

one “monitor” pod per node

Page 15: New Features of Kubernetes v1.2.0 beta

● introduced in v1.1● part of extensions api● smoothens deployment process of creating new resources and updating them● supported resource are Pods and Replication Controllers.● while updating, it ensures sufficient capacity of new pod(s) available to serve

and deleting old ones.

Deployments

@girag

Page 16: New Features of Kubernetes v1.2.0 beta

apiVersion: extensions/v1beta1kind: Deploymentmetadata: name: appsvr-deploymentspec: replicas: 3 template: metadata: labels: app: appsvr spec: containers: - name: appsvr image: bm/appsvr:v1 ports: - containerPort: 8080

DeploymentsapiVersion: extensions/v1beta1kind: Deploymentmetadata: name: appsvr-deploymentspec: replicas: 5 template: metadata: labels: app: appsvr spec: containers: - name: appsvr image: bm/appsvr:v2 ports: - containerPort: 8080

@girag

Page 17: New Features of Kubernetes v1.2.0 beta

apiVersion: extensions/v1beta1kind: Deploymentmetadata: name: appsvr-deploymentspec: replicas: 3 template: metadata: labels: app: appsvr spec: containers: - name: appsvr image: bm/appsvr:v1 ports: - containerPort: 8080

DeploymentsapiVersion: extensions/v1beta1kind: Deploymentmetadata: name: appsvr-deploymentspec: replicas: 5 template: metadata: labels: app: appsvr spec: containers: - name: appsvr image: bm/appsvr:v2 ports: - containerPort: 8080

$ kubectl create -f dep.yaml$ kubectl apply -f dep.yaml

@girag

creates 3 replica of appsvr:v1 pods

update 3 pod with appsvr:v2 when no more outstanding load && creates 2 more replica of appsvr:v2 pods

Page 18: New Features of Kubernetes v1.2.0 beta

● introduced in v1.1● part of extensions api● small in size● contains sensitive data like password, access-token, keys● usage

○ file in mounted volume○ used by kublet while pulling images to build pod

Secrets

@girag

Page 19: New Features of Kubernetes v1.2.0 beta

apiVersion: v1kind: Secretmetadata: name: user-profiletype: Opaquedata: user: graha password: dmFsdWUtMQ0K

SecretsapiVersion: v1kind: Podmetadata: name: secret-access-podspec: containers:

- name: tester image: kubernetes/mounttest:0.1 command: [ "/mt", "--file_content=/etc/profile/user" ] volumeMounts: # name must match the volume name below - name: profile mountPath: /etc/profile volumes:

- name: profile secret: secretName: user-profile restartPolicy: Never @girag

Page 20: New Features of Kubernetes v1.2.0 beta

apiVersion: v1kind: Secretmetadata: name: user-profiletype: Opaquedata: user: graha password: dmFsdWUtMQ0K

SecretsapiVersion: v1kind: Podmetadata: name: secret-access-podspec: containers:

- name: tester image: kubernetes/mounttest:0.1 command: [ "/mt", "--file_content=/etc/profile/user" ] volumeMounts: # name must match the volume name below - name: profile mountPath: /etc/profile volumes:

- name: profile secret: secretName: user-profile restartPolicy: Never @girag

creates a secret store for

user-profile

mounted as file system into /etc/profile

Page 21: New Features of Kubernetes v1.2.0 beta

● introduced in v1● part of core api● flexible configuration model for k8s● simplify storing configuration profile for application● dynamic distribution of configuration● usage

○ as environment variable○ in volume○ consistent data even from updating configuration model

ConfigMap

@girag

Page 22: New Features of Kubernetes v1.2.0 beta

apiVersion: v1kind: ConfigMapmetadata: name: bm-env-configdata: design-cache: 100 app-cache: 100 n-cmp-thread: 5

ConfigMap

@girag

apiVersion: v1kind: Podmetadata: name: config-test-podspec: containers: - name: config-test-container image: gcr.io/google_containers/busybox command: [ "/bin/sh", "cat", "/etc/config/bm.env" ] volumeMounts: - name: config-volume mountPath: /etc/config volumes: - name: config-volume configMap: name: bm-env-config restartPolicy: Never

Page 23: New Features of Kubernetes v1.2.0 beta

apiVersion: v1kind: ConfigMapmetadata: name: bm-env-configdata: design-cache: 100 app-cache: 100 n-cmp-thread: 5

ConfigMap

@girag

apiVersion: v1kind: Podmetadata: name: config-test-podspec: containers: - name: config-test-container image: gcr.io/google_containers/busybox command: [ "/bin/sh", "cat", "/etc/config/bm.env" ] volumeMounts: - name: config-volume mountPath: /etc/config volumes: - name: config-volume configMap: name: bm-env-config restartPolicy: Never

creates a configuration store for bm-env like secrets

mounted as file system into /etc/config

Page 24: New Features of Kubernetes v1.2.0 beta

● Locate our work○ www.gopaddle.io○ www.bluemeric.com○ http://www.bluemeric.com/blog/

● Reach us○ @bluemeric○ http://www.bluemeric.com/contact/

Q&A

@girag