This topic shows you how to create a workload on GKE on AWS and expose it internally to your cluster.
Before you begin
Before you start using GKE on AWS, make sure you have performed the following tasks:
- Complete the Prerequisites.
- Install a management service.
- Create a user cluster.
- From your
anthos-gketo switch context to your user cluster.
cd anthos-aws env HTTP_PROXY=http://localhost:8118 \ anthos-gke aws clusters get-credentials CLUSTER_NAME
Launch an NGINX deployment
In this section, you create a
of the NGINX webserver named
kubectl createto create the deployment.
env HTTP_PROXY=http://localhost:8118 \ kubectl create deployment --image nginx my-nginx
kubectlto get the status of the deployment. Note the Pod's
env HTTP_PROXY=http://localhost:8118 \ kubectl get deployment
Exposing your pods
This section shows how to expose the deployment internally in your cluster and
kubectl port-forward to open a tunnel from the Deployment to your local
Expose the Deployment to the cluster with
env HTTP_PROXY=http://localhost:8118 \ kubectl expose deployment my-nginx --port=80
The deployment is now accessible from within the cluster.
80in the Deployment to port
8080on your local machine with
env HTTP_PROXY=http://localhost:8118 \ kubectl port-forward deployment/my-nginx 8080:80
curlor your web browser. The default NGINX web page appears.
View your deployment on Google Cloud Console
If your cluster is connected to Google Cloud Console, you can view your deployment in the GKE Workloads page. To view your workload, perform the following steps:
In your browser, visit the Google Kubernetes Engine Workloads page.
The list of Workloads appears.
Click the name of your workload,
my-nginx. The Deployment details screen appears.
From this screen, you can get details on your deployment; view and edit YAML configuration; and take other Kubernetes actions.
For more information on options available from this page, see Deploying a stateless application in the GKE documentation.
To delete the your NGINX deployment, use
env HTTP_PROXY=http://localhost:8118 \ kubectl delete service my-nginx &&\ kubectl delete deployment my-nginx
You can use other types of Kubernetes Workloads with GKE on AWS. See the GKE documentation for more information on Deploying workloads.