Oracle Cloud Infrastructure Documentation

Deploying a Sample Nginx App on a Cluster Using kubectl

Having created a Kubernetes cluster using Container Engine for Kubernetes, you'll typically want to try it out by deploying an application on the nodes in the cluster. For convenience, the Cluster page includes a Getting Started tab that makes it easy to view and copy the commands to:

  • download the kubeconfig configuration file for the cluster
  • download and deploy a sample Nginx application using the Kubernetes command line tool kubectl from the instructions in a manifest file
  • start the Kubernetes Dashboard to view the deployed application running on nodes in the cluster

To deploy the sample nginx application:

  1. If you haven't done so already, download the cluster's kubeconfig configuration file. If the file does not have the expected default name and location of $HOME/.kube/config, set the KUBECONFIG environment variable to point to the file. See Downloading a kubeconfig File to Enable Cluster Access.
  2. In a terminal window, deploy the sample Nginx application by entering kubectl create -f https://k8s.io/docs/tasks/run-application/deployment.yaml

    Tip

    If the command fails to connect to https://k8s.io/docs/tasks/run-application/deployment.yaml , go to the url in a browser and download the manifest file deployment.yaml to a local directory. Repeat the kubectl create command and specify the local location of the deployment.yaml file.

  3. Use the Kubernetes Dashboard or kubectl to confirm that the sample application has deployed successfully. For example:

    1. Enter kubectl proxy to start the Kubernetes Dashboard.
    2. Open a browser and go to http://localhost:8001/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/ to display the Kubernetes Dashboard.
    3. Click Overview to see the applications deployed on the cluster.

You can see the Nginx sample application has been deployed as two pods, on two nodes in the cluster.