Deploy a workload using the MKE web UI

This example defines a Kubernetes deployment object for an NGINX server.

Deploy an NGINX server

  1. Log in to the MKE web UI.

  2. In the left-side navigation menu, navigate to Kubernetes and click Create.

  3. In the Namespace drop-down, select default.

  4. Paste the following configuration details in the Object YAML editor:

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: nginx-deployment
    spec:
      selector:
        matchLabels:
          app: nginx
      replicas: 2
      template:
        metadata:
          labels:
            app: nginx
        spec:
          containers:
          - name: nginx
            image: nginx:1.7.9
            ports:
            - containerPort: 80
    

    This YAML file specifies an earlier version of NGINX, which you will update in a later section of this topic.

  5. Click Create.

  6. Navigate to Kubernetes > Namespaces, hover over the default namespace, and select Set Context.

Inspect the deployment

You can review the status of your deployment in the Kubernetes section of the left-side navigation panel.

  1. In the left-side navigation panel, navigate to Kubernetes > Controllers to review the resource controllers created for the NGINX server.

  2. Click the nginx-deployment controller.

  3. To review the values used to create the deployment, click the gear icon in the upper right corner.

  4. In the left-side navigation panel, navigate to Kubernetes > Pods to review the Pods that are provisioned for the NGINX server.

  5. Click one of the Pods.

  6. In the Overview tab, review the Pod phase, IP address, and other properties.

Expose the server

The NGINX server is operational, but it is not accessible from outside of the cluster. Create a YAML file to add a NodePort service, which exposes the server on a specified port.

  1. In the left-side navigation menu, navigate to Kubernetes and click Create.

  2. In the Namespace drop-down, select default.

  3. Paste the following configuration details in the Object YAML editor:

    apiVersion: v1
    kind: Service
    metadata:
      name: nginx
      labels:
        app: nginx
    spec:
      type: NodePort
      ports:
        - port: 80
          nodePort: 32768
      selector:
        app: nginx
    

    The service connects internal port 80 of the cluster to the external port 32768.

  4. Click Create, and the Services page opens.

  5. Select the nginx service and in the Overview tab, scroll to the Ports section.

  6. To review the default NGINX page, navigate to <node-ip>:<nodeport> in your browser.

    Note

    To display the NGINX page, you may need to add a rule in your cloud provider firewall settings to allow inbound traffic on the port specified in the YAML file.

The YAML definition connects the service to the NGINX server using the app label nginx and a corresponding label selector.

Update the deployment

MKE supports updating an existing deployment by applying an updated YAML file. In this example, you will scale the server up to four replicas and update NGINX to a later version.

  1. In the left-side navigation panel, navigate to Kubernetes > Controllers and select nginx-deployment.

  2. To edit the deployment, click the gear icon in the upper right corner.

  3. Update the number of replicas from 2 to 4.

  4. Update the value of image from nginx:1.7.9 to nginx:1.8.

  5. Click Save to update the deployment with the new configuration settings.

  6. To review the newly-created replicas, in the left-side navigation panel, navigate to Kubernetes > Pods.

The content of the updated YAML file is as follows:

...
spec:
  progressDeadlineSeconds: 600
  replicas: 4
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      app: nginx
  strategy:
    rollingUpdate:
      maxSurge: 25%
      maxUnavailable: 25%
    type: RollingUpdate
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: nginx
    spec:
      containers:
      - image: nginx:1.8
...

See also