LATEST VERSION: v1.2 - RELEASE NOTES
Pivotal Container Service v1.2

Deploying and Accessing Basic Workloads

Page last updated:

This topic describes how to deploy and access basic workloads in Pivotal Container Service (PKS).

If you use Google Cloud Platform (GCP), Amazon Web Services (AWS), or vSphere with NSX-T integration, your cloud provider can configure an external load balancer for your workload. See Access Workloads Using an External Load Balancer.

If you use AWS, you can also access your workload using an internal load balancer. See the AWS Prerequisites section, and then Access Workloads Using an Internal AWS Load Balancer.

If you use vSphere without NSX-T, you can choose to configure your own external load balancer or expose static ports to access your workload without a load balancer. See Access Workloads without a Load Balancer.

AWS Prerequisites

If you use AWS, perform the following steps before you create a load balancer:

  1. In the AWS Management Console, create or locate a public subnet for each availability zone (AZ) you are deploying to. A public subnet has a route table that directs Internet-bound traffic to the Internet gateway.

  2. On the command line, run pks cluster CLUSTER-NAME, replacing CLUSTER-NAME with the name of your cluster.

  3. Record the unique identifier for the cluster.

  4. In the AWS Management Console, tag each public subnet based on the table below, replacing CLUSTER-UUID with the unique identifier of the cluster. Leave the Value field blank.

    Key Value
    kubernetes.io/cluster/service-instance_CLUSTER-UUID empty

    Note: AWS limits the number of tags on a subnet to 100.

Access Workloads Using an External Load Balancer

If you use GCP, AWS, or vSphere with NSX-T, follow the steps below to deploy and access basic workloads using a load balancer configured by your cloud provider.

Note: This approach creates a dedicated load balancer for each workload. This may be an inefficient use of resources in clusters with many apps.

  1. Expose the workload using a Service with type: LoadBalancer. See the Kubernetes documentation for more information about the LoadBalancer Service type.

  2. Download the spec for a basic NGINX app from the cloudfoundry-incubator/kubo-ci GitHub repository.

  3. Run kubectl create -f nginx.yml to deploy the basic NGINX app. This command creates three pods (replicas) that span three worker nodes.

  4. Wait until your cloud provider creates a dedicated load balancer and connects it to the worker nodes on a specific port.

  5. Run kubectl get svc nginx and retrieve the load balancer IP address and port number.

  6. On the command line of a server with network connectivity and visibility to the IP address of the worker node, run curl http://EXTERNAL-IP:PORT to access the app. Replace EXTERNAL-IP with the IP address of the load balancer and PORT with the port number.

Access Workloads Using an Internal AWS Load Balancer

If you use AWS, follow the steps below to deploy and access basic workloads using an internal load balancer configured by your cloud provider.

Note: This approach creates a dedicated load balancer for each workload. This may be an inefficient use of resources in clusters with many apps.

  1. Expose the workload using a Service with type: LoadBalancer. See the Kubernetes documentation for more information about the LoadBalancer Service type.

  2. Download the spec for a basic NGINX app from the cloudfoundry-incubator/kubo-ci GitHub repository.

  3. In the services metadata section of the manifest, add an annotations tag.

    For example:

    apiVersion: v1
    kind: Service
    metadata:
      labels:
        name: nginx
      annotations:
            service.beta.kubernetes.io/aws-load-balancer-internal: 0.0.0.0/0
      name: nginx
    spec:
      ports:
        - port: 80
      selector:
        app: nginx
      type: LoadBalancer
    
  4. Run kubectl create -f nginx.yml to deploy the basic NGINX app. This command creates three pods (replicas) that span three worker nodes.

  5. Wait until your cloud provider creates a dedicated load balancer and connects it to the worker nodes on a specific port.

  6. Run kubectl get svc nginx and retrieve the load balancer IP address and port number.

  7. On the command line of a server with network connectivity and visibility to the IP address of the worker node, run curl http://EXTERNAL-IP:PORT to access the app. Replace EXTERNAL-IP with the IP address of the load balancer and PORT with the port number.

Access Workloads without a Load Balancer

If you use vSphere without NSX-T integration, you do not have a load balancer configured by your cloud provider. You can choose to configure your own external load balancer or follow the procedures in this section to access your workloads without a load balancer.

If you do not use an external load balancer, you can configure the NGINX service to expose a static port on each worker node. From outside the cluster, you can reach the service at http://NODE-IP:NODE-PORT.

To expose a static port on your workload, perform the following steps:

  1. Download the spec for a basic NGINX app from the cloudfoundry-incubator/kubo-ci GitHub repository.

  2. Run kubectl create -f nginx.yml to deploy the basic NGINX app. This command creates three pods (replicas) that span three worker nodes.

  3. Expose the workload using a Service with type: NodePort. See the Kubernetes documentation for more information about the NodePort Service type.

  4. Retrieve the IP address for a worker node with a running NGINX pod.

    Note: If you deployed more than four worker nodes, some worker nodes may not contain a running NGINX pod. Select a worker node that contains a running NGINX pod.

    You can retrieve the IP address for a worker node with a running NGINX pod in one of the following ways:

    • On the command line, run kubectl get nodes -L spec.ip.
    • On the Ops Manager command line, run bosh vms to find the IP address.
  5. On the command line, run kubectl get svc nginx. Find the node port number in the 3XXXX range.

  6. On the command line of a server with network connectivity and visibility to the IP address of the worker node, run curl http://NODE-IP:NODE-PORT to access the app. Replace NODE-IP with the IP address of the worker node, and NODE-PORT with the node port number.


Please send any feedback you have to pks-feedback@pivotal.io.

Create a pull request or raise an issue on the source for this page in GitHub