Deploy a workload using the MKE web UI¶
This example defines a Kubernetes deployment object for an NGINX server.
Deploy an NGINX server¶
Log in to the MKE web UI.
In the left-side navigation menu, navigate to Kubernetes and click Create.
In the Namespace drop-down, select default.
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.
Click Create.
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.
In the left-side navigation panel, navigate to Kubernetes > Controllers to review the resource controllers created for the NGINX server.
Click the nginx-deployment controller.
To review the values used to create the deployment, click the slider icon in the upper right corner.
In the left-side navigation panel, navigate to Kubernetes > Pods to review the Pods that are provisioned for the NGINX server.
Click one of the Pods.
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.
In the left-side navigation menu, navigate to Kubernetes and click Create.
In the Namespace drop-down, select default.
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 port32768
.Click Create, and the Services page opens.
Select the nginx service and in the Overview tab, scroll to the Ports section.
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.
In the left-side navigation panel, navigate to Kubernetes > Controllers and select nginx-deployment.
To edit the deployment, click the gear icon in the upper right corner.
Update the number of
replicas
from2
to4
.Update the value of
image
fromnginx:1.7.9
tonginx:1.8
.Click Save to update the deployment with the new configuration settings.
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