Kubernetes first steps
With a cluster in place, let's create a trivial service.
apiVersion: v1
kind: Service
metadata:
name: hello-kubernetes
spec:
type: LoadBalancer
ports:
- port: 80
targetPort: 8080
selector:
app: hello-kubernetes
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: hello-kubernetes
spec:
replicas: 5
selector:
matchLabels:
app: hello-kubernetes
template:
metadata:
labels:
app: hello-kubernetes
spec:
containers:
- name: hello-kubernetes
image: paulbouwer/hello-kubernetes:1.8
ports:
- containerPort: 8080
With a kubectl apply -f hello.yaml
everything gets deployed.
NAME READY STATUS RESTARTS AGE
pod/hello-kubernetes-594f6f475f-72cqj 1/1 Running 0 36s
pod/hello-kubernetes-594f6f475f-jbspc 1/1 Running 0 36s
pod/hello-kubernetes-594f6f475f-krxfl 1/1 Running 0 36s
pod/hello-kubernetes-594f6f475f-lz566 1/1 Running 0 36s
pod/hello-kubernetes-594f6f475f-nzxw6 1/1 Running 0 36s
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 22h
service/whoami LoadBalancer 10.103.97.96 10.50.99.0 80:30784/TCP 22h
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/hello-kubernetes 5/5 5 5 36s
NAME DESIRED CURRENT READY AGE
replicaset.apps/hello-kubernetes-594f6f475f 5 5 5 36s