Run a deployment in your cluster.
If you created a new cluster or the cluster you attached is empty, you can optionally run a small deployment in your cluster to exercise the observability features of VMware Tanzu Mission Control. This procedure creates two deployments (coffee
and tea
) exposed as services (coffee-svc
and tea-svc
), each running a different image (nginxdemos/hello
and nginxdemos/hello:plain-text
).
Prerequisites
Before you can run a deployment in your cluster, you must have a cluster and be connected to it with kubectl.
If you provisioned your cluster through Tanzu Mission Control, you must apply a pod security policy to relax the security profile of the cluster, because this example runs an Nginx app that runs as root. For more information, see Relaxing Pod Security in a Provisioned Cluster in Using VMware Tanzu Mission Control.
Procedure
- Create the cafe-services.yaml file with the following contents:
apiVersion: apps/v1
kind: Deployment
metadata:
name: coffee
spec:
replicas: 2
selector:
matchLabels:
app: coffee
template:
metadata:
labels:
app: coffee
spec:
containers:
- name: coffee
image: nginxdemos/hello
ports:
- containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
name: coffee-svc
spec:
ports:
- port: 80
targetPort: 80
protocol: TCP
name: http
selector:
app: coffee
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: tea
spec:
replicas: 3
selector:
matchLabels:
app: tea
template:
metadata:
labels:
app: tea
spec:
containers:
- name: tea
image: nginxdemos/hello:plain-text
ports:
- containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
name: tea-svc
labels:
spec:
ports:
- port: 80
targetPort: 80
protocol: TCP
name: http
selector:
app: tea
- Make sure kubectl is connected to your cluster, and run the following command to create and expose the deployments.
kubectl create -f cafe-services.yaml