apiVersion: apps/v1
kind: Deployment
metadata:
name: hello
spec:
selector:
matchLabels:
app: hello
replicas: 1
template:
metadata:
labels:
app: hello
spec:
containers:
- name: hello
image: numberly/hello
deployment.yaml
$ kubectl apply -f deployment.yaml
$ kubectl scale --replicas=4 deployment hello
apiVersion: v1
kind: Service
metadata:
name: hello
spec:
ports:
- protocol: TCP
port: 80
targetPort: 8000
selector:
app: hello
type: ClusterIP
service.yaml
$ kubectl apply -f service.yaml
$ kubectl get all
NAME READY STATUS RESTARTS AGE
pod/hello-5688899d46-9nmzb 1/1 Running 0 23s
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/hello ClusterIP 10.16.0.122 <none> 80/TCP 19s
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/hello 1/1 1 1 24s
NAME DESIRED CURRENT READY AGE
replicaset.apps/hello-5688899d46 1 1 1 24s
Software engineers
Infrastructure engineers
Kelsey Hightower