Introduction To Kubernetes
Introduction To Kubernetes
An Introduction
CC-BY 4.0
Kubernetes v1.15 07/2019
Before We Begin
Requirements:
● Minikube:
https://github.com/kubernetes/minikube
● Virtualbox*:
https://www.virtualbox.org/wiki/Downloads
● kubectl:
https://kubernetes.io/docs/tasks/tools/install-kubectl/
● k8s-intro-tutorials repo:
https://github.com/mrbobbytables/k8s-intro-tutorials
Before We Begin
Go here for install instructions
https://goo.gl/1HV3Tu
Kubernetes
An Introduction
CC-BY 4.0
Kubernetes v1.15 07/2019
$ whoami - Bob
Bob Killen
[email protected]
Senior Research Cloud Administrator
CNCF Ambassador
Github: @mrbobbytables
Twitter: @mrbobbytables
$ whoami - Jeff
Jeffrey Sica
[email protected]
Senior Research Database Administrator
Github: @jeefy
Twitter: @jeefy
Project
Overview
What Does “Kubernetes” Mean?
Image Source
What is Kubernetes?
● Project that was spun out of Google as an open source
container orchestration platform.
● Built from the lessons learned in the experiences of
developing and running Google’s Borg and Omega.
● Designed from the ground-up as a loosely coupled
collection of components centered around deploying,
maintaining and scaling workloads.
What Does Kubernetes do?
● Known as the linux kernel of distributed systems.
● Abstracts away the underlying hardware of the
nodes and provides a uniform interface for workloads to
be both deployed and consume the shared pool of
resources.
● Works as an engine for resolving state by converging
actual and the desired state of the system.
Decouples Infrastructure and Scaling
● All services within Kubernetes are natively
Load Balanced.
● Can scale up and down dynamically.
● Used both to enable self-healing and
seamless upgrading or rollback of
applications.
Self Healing
Kubernetes will ALWAYS try and steer the cluster to its
desired state.
07/2019
Project Stats
A Couple
Key Concepts...
Pods
● Atomic unit or smallest
“unit of work”of Kubernetes.
● Pods are one or MORE
containers that share
volumes, a network
namespace, and are a part
of a single context.
Pods
They are
also
Ephemeral!
Services
● Unified method of accessing
the exposed workloads of Pods.
● Durable resource
○ static cluster IP
○ static namespaced
DNS name
Services
● Unified method of accessing
the exposed workloads of Pods.
● Durable resource
○ static cluster IP
○ static namespaced
DNS name
NOT Ephemeral!
Architecture
Overview
Control Plane
Components
Architecture Overview
Control Plane Components
● kube-apiserver
● etcd
● kube-controller-manager
● kube-scheduler
kube-apiserver
● Provides a forward facing REST interface into the
kubernetes control plane and datastore.
● All clients and other applications interact with
kubernetes strictly through the API Server.
● Acts as the gatekeeper to the cluster by handling
authentication and authorization, request validation,
mutation, and admission control in addition to being the
front-end to the backing datastore.
etcd
● etcd acts as the cluster datastore.
● Purpose in relation to Kubernetes is to provide a strong,
consistent and highly available key-value store for
persisting cluster state.
● Stores objects and config information.
etcd
Uses “Raft Consensus”
among a quorum of systems
to create a fault-tolerant
consistent “view” of the
cluster.
https://raft.github.io/
Image Source
kube-controller-manager
● Serves as the primary daemon that
manages all core component control loops.
● Monitors the cluster state via the apiserver
and steers the cluster towards the
desired state.
Architecture Overview
Node Components
● kubelet
● kube-proxy
● Container Runtime Engine
kubelet
● Acts as the node agent responsible for managing the
lifecycle of every pod on its host.
● Kubelet understands YAML container manifests that it
can read from several sources:
○ file path
○ HTTP Endpoint
○ etcd watch acting on any changes
○ HTTP Server mode accepting container manifests
over a simple API.
kube-proxy
● Manages the network rules on each node.
● Performs connection forwarding or load balancing for
Kubernetes cluster services.
● Available Proxy Modes:
○ Userspace
○ iptables
○ ipvs (default if supported)
Container Runtime Engine
● A container runtime is a CRI (Container Runtime
Interface) compatible application that executes and
manages containers.
○ Containerd (docker)
○ Cri-o
○ Rkt
○ Kata (formerly clear and hyper)
○ Virtlet (VM CRI compatible runtime)
Optional
Services
Architecture Overview
cloud-controller-manager
● Daemon that provides cloud-provider specific
knowledge and integration capability into the core
control loop of Kubernetes.
● The controllers include Node, Route, Service, and add
an additional controller to handle things such as
PersistentVolume Labels.
Cluster DNS
● Provides Cluster Wide DNS for Kubernetes
Services.
○ Built on top of CoreDNS
Kube Dashboard
A limited, general
purpose web front end
for the Kubernetes
Cluster.
Heapster / Metrics API Server
● Provides metrics for use with other
Kubernetes Components.
○ Heapster (deprecated, removed in Dec)
○ Metrics API (current)
Networking
Architecture Overview
Kubernetes Networking
● Pod Network
○ Cluster-wide network used for pod-to-pod
communication managed by a CNI (Container
Network Interface) plugin.
● Service Network
○ Cluster-wide range of Virtual IPs managed by kube-
proxy for service discovery.
Container Network Interface (CNI)
● Pod networking within Kubernetes is plumbed via the
Container Network Interface (CNI).
● Functions as an interface between the container
runtime and a network implementation plugin.
● CNCF Project
● Uses a simple JSON Schema.
CNI Overview
CNI Overview
CNI Plugins
apiVersion: v1
kind: Pod
metadata:
name: pod-example
namespace: default
uid: f8798d82-1185-11e8-94ce-080027b3c7a6
Object Expression - YAML
● Files or other representations of Kubernetes Objects are generally
represented in YAML.
● A “Human Friendly” data serialization standard.
● Uses white space (specifically spaces) alignment to denote ownership.
● Three basic data types:
○ mappings - hash or dictionary,
○ sequences - array or list
○ scalars - string, number, boolean etc
Object Expression - YAML
apiVersion: v1
kind: Pod
metadata:
name: yaml
spec:
containers:
- name: container1
image: nginx
- name: container2
image: alpine
Object Expression - YAML
apiVersion: v1
kind: Pod Scalar
metadata:
Mapping
Hash
name: yaml
Dictionary spec:
containers:
- name: container1
image: nginx
- name: container2
image: alpine Sequence
Array
List
YAML vs JSON
apiVersion: v1 {
kind: Pod "apiVersion": "v1",
metadata: "kind": "Pod",
"metadata": {
name: pod-example "name": "pod-example"
spec: },
containers: "spec": {
- name: nginx "containers": [
image: nginx:stable-alpine {
ports: "name": "nginx",
- containerPort: 80 "image": "nginx:stable-alpine",
"ports": [ { "containerPort": 80 } ]
}
]
}
}
Object Model - Workloads
● Workload related objects within Kubernetes
have an additional two nested fields spec
and status.
○ spec - Describes the desired state or
configuration of the object to be created.
○ status - Is managed by Kubernetes and describes
the actual state of the object and its history.
Workload Object Example
Example Object Example Status Snippet
status:
apiVersion: v1 conditions:
kind: Pod - lastProbeTime: null
metadata: lastTransitionTime: 2018-02-14T14:15:52Z
Namespaces
Pods Services
Labels Selectors
Namespaces
Namespaces are a logical cluster or environment, and are
the primary method of partitioning a cluster or scoping
access.
* https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#syntax-and-character-set
Label Example
apiVersion: v1
kind: Pod
metadata:
name: pod-label-example
labels:
app: nginx
env: prod
spec:
containers:
- name: nginx
image: nginx:stable-alpine
ports:
- containerPort: 80
Selectors
Selectors use labels to filter apiVersion: v1
kind: Pod
or select objects, and are metadata:
name: pod-label-example
used throughout Kubernetes. labels:
app: nginx
env: prod
spec:
containers:
- name: nginx
image: nginx:stable-alpine
ports:
- containerPort: 80
nodeSelector:
gpu: nvidia
Selector Example
apiVersion: v1
kind: Pod
metadata:
name: pod-label-example
labels:
app: nginx
env: prod
spec:
containers:
- name: nginx
image: nginx:stable-alpine
ports:
- containerPort: 80
nodeSelector:
gpu: nvidia
Selector Types
Equality based selectors allow for Set-based selectors are supported
simple filtering (=,==, or !=). on a limited subset of objects.
However, they provide a method of
filtering on a set of values, and
supports multiple operators including:
in, notin, and exist.
selector: selector:
matchLabels: matchExpressions:
gpu: nvidia - key: gpu
operator: in
values: [“nvidia”]
Services
● Unified method of accessing the exposed workloads
of Pods.
● Durable resource (unlike Pods)
○ static cluster-unique IP
○ static namespaced DNS name
<service name>.<namespace>.svc.cluster.local
Services
● Target Pods using equality based selectors.
● Uses kube-proxy to provide simple load-balancing.
● kube-proxy acts as a daemon that creates local
entries in the host’s iptables for every service.
Service Types
There are 4 major service types:
● ClusterIP (default)
● NodePort
● LoadBalancer
● ExternalName
ClusterIP Service
apiVersion: v1
ClusterIP services exposes a kind: Service
service on a strictly cluster metadata:
name: example-prod
internal virtual IP. spec:
selector:
app: nginx
env: prod
ports:
- protocol: TCP
port: 80
targetPort: 80
Cluster IP Service
Name: example-prod
Selector: app=nginx,env=prod
Type: ClusterIP
IP: 10.96.28.176
Port: <unset> 80/TCP
TargetPort: 80/TCP
Endpoints: 10.255.16.3:80,
10.255.16.4:80
/ # nslookup example-prod.default.svc.cluster.local
Name: example-prod.default.svc.cluster.local
Address 1: 10.96.28.176 example-prod.default.svc.cluster.local
NodePort Service
● NodePort services extend apiVersion: v1
kind: Service
the ClusterIP service. metadata:
name: example-prod
● Exposes a port on every spec:
type: NodePort
node’s IP. selector:
● Port can either be statically app: nginx
env: prod
defined, or dynamically taken ports:
- nodePort: 32410
from a range between 30000- protocol: TCP
32767. port: 80
targetPort: 80
NodePort Service
Name: example-prod
Selector: app=nginx,env=prod
Type: NodePort
IP: 10.96.28.176
Port: <unset> 80/TCP
TargetPort: 80/TCP
NodePort: <unset> 32410/TCP
Endpoints: 10.255.16.3:80,
10.255.16.4:80
LoadBalancer Service
● LoadBalancer services apiVersion: v1
kind: Service
extend NodePort. metadata:
name: example-prod
● Works in conjunction with an spec:
type: LoadBalancer
external system to map a selector:
cluster external IP to the app: nginx
env: prod
exposed service. ports:
protocol: TCP
port: 80
targetPort: 80
LoadBalancer Service
Name: example-prod
Selector: app=nginx,env=prod
Type: LoadBalancer
IP: 10.96.28.176
LoadBalancer
Ingress: 172.17.18.43
Port: <unset> 80/TCP
TargetPort: 80/TCP
NodePort: <unset> 32410/TCP
Endpoints: 10.255.16.3:80,
10.255.16.4:80
ExternalName Service
● ExternalName is used to apiVersion: v1
kind: Service
reference endpoints metadata:
name: example-prod
OUTSIDE the cluster. spec:
● Creates an internal type: ExternalName
spec:
CNAME DNS entry that externalName: example.com
aliases another.
Lab - github.com/mrbobbytables/k8s-intro-tutorials/blob/master/core
Exploring
the Core
Lab - github.com/mrbobbytables/k8s-intro-tutorials/blob/master/core
Exploring
the Core
● ReplicaSet
Deployment
DaemonSet
Workloads StatefulSet
Job
CronJob
Using Workloads
Workloads
Workloads within Kubernetes are higher level
objects that manage Pods or other higher level
objects.
R1 pod-template-hash:
676677fff
R2 pod-template-hash:
54f7ff7d6d
R1 pod-template-hash:
676677fff
R2 pod-template-hash:
54f7ff7d6d
R1 pod-template-hash:
676677fff
R2 pod-template-hash:
54f7ff7d6d
R1 pod-template-hash:
676677fff
R2 pod-template-hash:
54f7ff7d6d
R1 pod-template-hash:
676677fff
R2 pod-template-hash:
54f7ff7d6d
R1 pod-template-hash:
676677fff
R2 pod-template-hash:
54f7ff7d6d
volumeClaimTemplates:
- metadata:
Persistent Volumes associated with a
name: www StatefulSet will NOT be automatically
spec:
accessModes: [ "ReadWriteOnce" ] garbage collected when it’s associated
storageClassName: standard StatefulSet is deleted. They must manually
resources:
requests: be removed.
storage: 1Gi
Using Workloads
● Volumes
Persistent
Volumes
Storage Persistent
Volume Claims
StorageClass
Persistent Volume
Supported
Volumes
apiVersion: v1
● volumes: A list of volume objects to kind: Pod
metadata:
be attached to the Pod. Every object name: volume-example
spec:
within the list must have it’s own containers:
- name: nginx
unique name. image: nginx:stable-alpine
volumeMounts:
mountPath. args:
- while true; do
date >> /html/index.html;
sleep 5;
done
volumeMounts:
- name: html
mountPath: /html
volumes:
- name: html
emptyDir: {}
Volumes
apiVersion: v1
● volumes: A list of volume objects to kind: Pod
metadata:
be attached to the Pod. Every object name: volume-example
spec:
within the list must have it’s own containers:
- name: nginx
unique name. image: nginx:stable-alpine
volumeMounts:
mountPath. args:
- while true; do
date >> /html/index.html;
sleep 5;
done
volumeMounts:
- name: html
mountPath: /html
volumes:
- name: html
emptyDir: {}
Volumes
apiVersion: v1
● volumes: A list of volume objects to kind: Pod
metadata:
be attached to the Pod. Every object name: volume-example
spec:
within the list must have it’s own containers:
- name: nginx
unique name. image: nginx:stable-alpine
volumeMounts:
mountPath. args:
- while true; do
date >> /html/index.html;
sleep 5;
done
volumeMounts:
- name: html
mountPath: /html
volumes:
- name: html
emptyDir: {}
Persistent Volumes
● A PersistentVolume (PV) represents a storage
resource.
● PVs are a cluster wide resource linked to a backing
storage provider: NFS, GCEPersistentDisk, RBD etc.
● Generally provisioned by an administrator.
● Their lifecycle is handled independently from a pod
● CANNOT be attached to a Pod directly. Relies on a
PersistentVolumeClaim
PersistentVolumeClaims
● A PersistentVolumeClaim (PVC) is a namespaced
request for storage.
● Satisfies a set of requirements instead of mapping to a
storage resource directly.
● Ensures that an application’s ‘claim’ for storage is
portable across numerous backends or providers.
Persistent Volumes and Claims
Cluster Cluster
Users Admins
PersistentVolume
● capacity.storage: The total amount of apiVersion: v1
kind: PersistentVolume
available storage. metadata:
name: nfsserver
spec:
● volumeMode: The type of volume, capacity:
this can be either Filesystem or storage: 50Gi
volumeMode: Filesystem
Block. accessModes:
- ReadWriteOnce
● accessModes: A list of the supported - ReadWriteMany
persistentVolumeReclaimPolicy: Delete
methods of accessing the volume. storageClassName: slow
mountOptions:
Options include: - hard
- nfsvers=4.1
○ ReadWriteOnce nfs:
path: /exports
○ ReadOnlyMany server: 172.22.0.42
○ ReadWriteMany
PersistentVolume
● persistentVolumeReclaimPolicy: The apiVersion: v1
kind: PersistentVolume
behaviour for PVC’s that have been metadata:
name: nfsserver
deleted. Options include: spec:
capacity:
○ Retain - manual clean-up storage: 50Gi
volumeMode: Filesystem
○ Delete - storage asset deleted by accessModes:
- ReadWriteOnce
provider. - ReadWriteMany
persistentVolumeReclaimPolicy: Delete
● storageClassName: Optional name of storageClassName: slow
mountOptions:
the storage class that PVC’s can - hard
reference. If provided, ONLY PVC’s - nfsvers=4.1
nfs:
referencing the name consume use it. path: /exports
server: 172.22.0.42
● mountOptions: Optional mount options
for the PV.
PersistentVolumeClaim
● accessModes: The selected method of kind: PersistentVolumeClaim
apiVersion: v1
accessing the storage. This MUST be a metadata:
subset of what is defined on the target PV name: pvc-sc-example
or Storage Class. spec:
accessModes:
○ ReadWriteOnce - ReadWriteOnce
○ ReadOnlyMany resources:
requests:
○ ReadWriteMany storage: 1Gi
● resources.requests.storage: The storageClassName: slow
uid: 9df65c6e-1a69-11e8-ae10-
080027a3682b
4. provisioned PV is bound
to requesting PVC.
3. External storage system
creates a PV strictly satisfying
pv: pvc-9df65c6e-1a69-11e8-ae10-
the PVC request.
080027a3682b
StorageClass
● provisioner: Defines the ‘driver’ to be kind: StorageClass
apiVersion: storage.k8s.io/v1
used for provisioning of the external metadata:
name: standard
storage. provisioner: kubernetes.io/gce-pd
● parameters: A hash of the various parameters:
type: pd-standard
configuration parameters for the zones: us-central1-a, us-central1-b
provisioner. reclaimPolicy: Delete
● reclaimPolicy: The behaviour for the
backing storage when the PVC is
deleted.
○ Retain - manual clean-up
○ Delete - storage asset deleted by
provider
Available StorageClasses
● AWSElasticBlockStore ● iSCSI
● AzureFile ● Quobyte
● AzureDisk ● NFS
● CephFS ● RBD
● Cinder ● VsphereVolume
● FC ● PortworxVolume
● Flocker ● ScaleIO
● GCEPersistentDisk ● StorageOS
● Glusterfs ● Local
Internal
Provisioner
Lab - github.com/mrbobbytables/k8s-intro-tutorials/blob/master/storage
Working with
Volumes
● ConfigMap
Configuration Secret
$ cat info/city
Ann Arbor
$ cat info/state
Michigan
$ kubectl create configmap file-example --from-file=cm/city --from-file=cm/state
configmap "file-example" created
ConfigMap Example
All produce a ConfigMap with the same content!
$ cat info/city
Ann Arbor
$ cat info/state
Michigan
$ kubectl create configmap file-example --from-file=cm/city --from-file=cm/state
configmap "file-example" created
ConfigMap Example
All produce a ConfigMap with the same content!
$ cat info/city
Ann Arbor
$ cat info/state
Michigan
$ kubectl create configmap file-example --from-file=cm/city --from-file=cm/state
configmap "file-example" created
ConfigMap Example
All produce a ConfigMap with the same content!
$ cat info/city
Ann Arbor
$ cat info/state
Michigan
$ kubectl create configmap file-example --from-file=cm/city --from-file=cm/state
configmap "file-example" created
Secret
● Functionally identical to a ConfigMap.
● Stored as base64 encoded content.
● Encrypted at rest within etcd (if configured!).
● Ideal for username/passwords, certificates or other
sensitive information that should not be stored in a
container.
● Can be created from a manifest, literals, directories, or
from files directly.
Secret
● type: There are three different types of apiVersion: v1
kind: Secret
secrets within Kubernetes: metadata:
○ docker-registry - credentials used name: manifest-secret
type: Opaque
to authenticate to a container data:
registry username: ZXhhbXBsZQ==
○ generic/Opaque - literal values password: bXlwYXNzd29yZA==
from different sources
○ tls - a certificate based secret
● data: Contains key-value pairs of
base64 encoded content.
Secret Example
All produce a Secret with the same content!
apiVersion: v1 $ kubectl create secret generic literal-secret \
> --from-literal=username=example \
kind: Secret > --from-literal=password=mypassword
metadata: secret "literal-secret" created
name: manifest-example
type: Opaque $ cat info/username
data: example
$ cat info/password
username: ZXhhbXBsZQ== mypassword
password: bXlwYXNzd29yZA== $ kubectl create secret generic dir-secret --from-file=secret/
Secret "file-secret" created
$ cat secret/username
example
$ cat secret/password
mypassword
$ kubectl create secret generic file-secret --from-file=secret/username --from-file=secret/password
Secret "file-secret" created
Secret Example
All produce a Secret with the same content!
apiVersion: v1 $ kubectl create secret generic literal-secret \
> --from-literal=username=example \
kind: Secret > --from-literal=password=mypassword
metadata: secret "literal-secret" created
name: manifest-example
type: Opaque $ cat info/username
data: example
$ cat info/password
username: ZXhhbXBsZQ== mypassword
password: bXlwYXNzd29yZA== $ kubectl create secret generic dir-secret --from-file=secret/
Secret "file-secret" created
$ cat secret/username
example
$ cat secret/password
mypassword
$ kubectl create secret generic file-secret --from-file=secret/username --from-file=secret/password
Secret "file-secret" created
Secret Example
All produce a Secret with the same content!
apiVersion: v1 $ kubectl create secret generic literal-secret \
> --from-literal=username=example \
kind: Secret > --from-literal=password=mypassword
metadata: secret "literal-secret" created
name: manifest-example
type: Opaque $ cat info/username
data: example
$ cat info/password
username: ZXhhbXBsZQ== mypassword
password: bXlwYXNzd29yZA== $ kubectl create secret generic dir-secret --from-file=secret/
Secret "file-secret" created
$ cat secret/username
example
$ cat secret/password
mypassword
$ kubectl create secret generic file-secret --from-file=secret/username --from-file=secret/password
Secret "file-secret" created
Secret Example
All produce a Secret with the same content!
apiVersion: v1 $ kubectl create secret generic literal-secret \
> --from-literal=username=example \
kind: Secret > --from-literal=password=mypassword
metadata: secret "literal-secret" created
name: manifest-example
type: Opaque $ cat info/username
data: example
$ cat info/password
username: ZXhhbXBsZQ== mypassword
password: bXlwYXNzd29yZA== $ kubectl create secret generic dir-secret --from-file=secret/
Secret "file-secret" created
$ cat secret/username
example
$ cat secret/password
mypassword
$ kubectl create secret generic file-secret --from-file=secret/username --from-file=secret/password
Secret "file-secret" created
Injecting as Environment Variable
apiVersion: batch/v1 apiVersion: batch/v1
kind: Job kind: Job
metadata: metadata:
name: cm-env-example name: secret-env-example
spec: spec:
template: template:
spec: spec:
containers: containers:
- name: mypod - name: mypod
image: alpine:latest image: alpine:latest
command: [“/bin/sh”, “-c”] command: [“/bin/sh”, “-c”]
args: [“printenv CITY”] args: [“printenv USERNAME”]
env: env:
- name: CITY - name: USERNAME
valueFrom: valueFrom:
configMapKeyRef: secretKeyRef:
name: manifest-example name: manifest-example
key: city key: username
restartPolicy: Never restartPolicy: Never
Injecting as Environment Variable
apiVersion: batch/v1 apiVersion: batch/v1
kind: Job kind: Job
metadata: metadata:
name: cm-env-example name: secret-env-example
spec: spec:
template: template:
spec: spec:
containers: containers:
- name: mypod - name: mypod
image: alpine:latest image: alpine:latest
command: [“/bin/sh”, “-c”] command: [“/bin/sh”, “-c”]
args: [“printenv CITY”] args: [“printenv USERNAME”]
env: env:
- name: CITY - name: USERNAME
valueFrom: valueFrom:
configMapKeyRef: secretKeyRef:
name: manifest-example name: manifest-example
key: city key: username
restartPolicy: Never restartPolicy: Never
Injecting in a Command
apiVersion: batch/v1 apiVersion: batch/v1
kind: Job kind: Job
metadata: metadata:
name: cm-cmd-example name: secret-cmd-example
spec: spec:
template: template:
spec: spec:
containers: containers:
- name: mypod - name: mypod
image: alpine:latest image: alpine:latest
command: [“/bin/sh”, “-c”] command: [“/bin/sh”, “-c”]
args: [“echo Hello ${CITY}!”] args: [“echo Hello ${USERNAME}!”]
env: env:
- name: CITY - name: USERNAME
valueFrom: valueFrom:
configMapKeyRef: secretKeyRef:
name: manifest-example name: manifest-example
key: city key: username
restartPolicy: Never restartPolicy: Never
Injecting in a Command
apiVersion: batch/v1 apiVersion: batch/v1
kind: Job kind: Job
metadata: metadata:
name: cm-cmd-example name: secret-cmd-example
spec: spec:
template: template:
spec: spec:
containers: containers:
- name: mypod - name: mypod
image: alpine:latest image: alpine:latest
command: [“/bin/sh”, “-c”] command: [“/bin/sh”, “-c”]
args: [“echo Hello ${CITY}!”] args: [“echo Hello ${USERNAME}!”]
env: env:
- name: CITY - name: USERNAME
valueFrom: valueFrom:
configMapKeyRef: secretKeyRef:
name: manifest-example name: manifest-example
key: city key: username
restartPolicy: Never restartPolicy: Never
Injecting as a Volume
apiVersion: batch/v1 apiVersion: batch/v1
kind: Job kind: Job
metadata: metadata:
name: cm-vol-example name: secret-vol-example
spec: spec:
template: template:
spec: spec:
containers: containers:
- name: mypod - name: mypod
image: alpine:latest image: alpine:latest
command: [“/bin/sh”, “-c”] command: [“/bin/sh”, “-c”]
args: [“cat /myconfig/city”] args: [“cat /mysecret/username”]
volumeMounts: volumeMounts:
- name: config-volume - name: secret-volume
mountPath: /myconfig mountPath: /mysecret
restartPolicy: Never restartPolicy: Never
volumes: volumes:
- name: config-volume - name: secret-volume
configMap: secret:
name: manifest-example secretName: manifest-example
Injecting as a Volume
apiVersion: batch/v1 apiVersion: batch/v1
kind: Job kind: Job
metadata: metadata:
name: cm-vol-example name: secret-vol-example
spec: spec:
template: template:
spec: spec:
containers: containers:
- name: mypod - name: mypod
image: alpine:latest image: alpine:latest
command: [“/bin/sh”, “-c”] command: [“/bin/sh”, “-c”]
args: [“cat /myconfig/city”] args: [“cat /mysecret/username”]
volumeMounts: volumeMounts:
- name: config-volume - name: secret-volume
mountPath: /myconfig mountPath: /mysecret
restartPolicy: Never restartPolicy: Never
volumes: volumes:
- name: config-volume - name: secret-volume
configMap: secret:
name: manifest-example secretName: manifest-example
Lab - github.com/mrbobbytables/k8s-intro-tutorials/blob/master/configuration
Using ConfigMaps
and Secrets
Lab
Putting it all
Together
Where to go
From Here
kubernetes.io
Documentation
Examples
API Reference
Slack
Kubernetes CNCF
slack.k8s.io slack.cncf.io
07/2019
Other Communities
● Official Forum
https://discuss.kubernetes.io
● Subreddit
https://reddit.com/r/kubernetes
● StackOverflow
https://stackoverflow.com/questions/tagged/kubernetes
Meetups
Kubernetes CNCF
meetup.com/topics/kubernetes/ meetups.cncf.io
Europe:
China:
March 30 – April 2, 2020
TBD
North America: Amsterdam, Netherlands
November 18 - 21, 2019
San Diego, CA
07/2019
GitHub
SIGs
● Kubernetes components and features are
broken down into smaller self-managed
communities known as Special Interest
Groups (SIG).
● Hold weekly public recorded meetings and
have their own mailing lists and slack
channels.
SIG List
https://github.com/kubernetes/community/blob/master/sig-list.md
07/2019
Working Groups
● Similar to SIGs, but are topic focused, time-
bounded, or act as a focal point for cross-sig
coordination.
● Hold scheduled publicly recorded meetings
in addition to having their own mailing lists
and slack channels.
WG List
https://github.com/kubernetes/community/blob/master/sig-list.md
07/2019
Links
● Free Kubernetes Courses
https://www.edx.org/
● Interactive Kubernetes Tutorials
https://www.katacoda.com/courses/kubernetes
● Learn Kubernetes the Hard Way
https://github.com/kelseyhightower/kubernetes-the-hard-way
● Official Kubernetes Youtube Channel
https://www.youtube.com/c/KubernetesCommunity
● Official CNCF Youtube Channel
https://www.youtube.com/c/cloudnativefdn
● Track to becoming a CKA/CKAD (Certified Kubernetes Administrator/Application Developer)
https://www.cncf.io/certification/expert/
● Awesome Kubernetes
https://ramitsurana.gitbooks.io/awesome-kubernetes/content/
Questions?