Deploying a sample app

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. The following deployment 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).

What to do first

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, 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.

Deploy a sample app

Do the following to deploy a sample app on your cluster:

  1. 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
    
  2. 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
    
check-circle-line exclamation-circle-line close-line
Scroll to top icon