This "Hello World" sample demonstrates how to deploy a simple "Hello World" application to Kubernetes using the Cloud Code extension for Visual Studio Code. When you run the application, Cloud Code uses skaffold under the hood to build an image and deploy the project's Kubernetes manifests. To learn more about Kubernetes, explore the Kubernetes overview.
- What's in this sample
- Getting Started
- Next steps
- Sign up for user research
-
skaffold.yaml- A schema file that defines skaffold configurations (skaffold.yaml reference) -
kubernetes-manifests/- Contains Kubernetes YAML files for the Guestbook services and deployments, including:hello.deployment.yaml- deploys a pod with the 'java-hello-world' container imagehello.service.yaml- creates a load balancer and exposes the 'java-hello-world' service on an external IP in the cluster
Cloud Code uses minikube to create a free local cluster.
- Navigate to the Clusters explorer in the Cloud Code - Kubernetes sidebar using the left side Activity bar.
Note: in newer versions of VS Code, the Clusters explorer has been replaced with a dedicated Kubernetes section.
-
Click '+' in the title bar of the Clusters explorer to create a new cluster. If prompted, follow the instructions to log in to Google Cloud Platform.
-
Choose Minikube and then select minikube.
-
Select Start. Cloud Code will initiate a minikube cluster.
- Navigate to the Clusters explorer in the Cloud Code - Kubernetes sidebar using the left side Activity bar.
Note: in newer versions of VS Code, the Clusters explorer has been replaced with a dedicated Kubernetes section.
-
Click '+' in the title bar of the Clusters explorer to create a new cluster. If prompted, follow the instructions to log in to Google Cloud Platform.
-
Choose Google Kubernetes Engine. If you have existing clusters associated with your GCP project, you can select one from this dialog. To create a new cluster, click + Create a new GKE Cluster and follow these steps:
a. Choose Standard or Autopilot. For more information, see Comparing Autopilot and Standard modes.
b. If prompted, click Open to permit Cloud Code to open the Cloud Console.
c. In the Cloud Console, choose any configuration options that you want to customize and then click Create.
d. Once the cluster has finished being created, return to VS Code and click Refresh.
You can now select your newly created cluster.
-
The cluster you select will be added to the Clusters explorer and set as the default context. You can inspect the cluster's properties, make changes to the cluster's resources, and view logs by clicking the dropdown arrow next to the cluster name in the Clusters explorer.
-
Navigate to the Development Sessions explorer in the Cloud Code - Kubernetes sidebar using the Activity bar on the left side of the IDE.
-
Click the 'Play' icon in the title bar of the Development Sessions explorer to run the application. If prompted, confirm the current context and image registry.
-
View the build progress in the Development Sessions explorer. Once the build has finished, the URLs for your deployed app will be displayed under Port Forward URLs. Click on the 'Open Window' icon next to the service's URL to visit your deployed app.
-
To stop the application, click the stop icon on the Debug Toolbar.
If you created a GKE cluster for this tutorial, be sure to delete your cluster to avoid incurring charges.
- Try debugging your app using Cloud Code
- Navigate the Kubernetes Engine Explorer
- Learn how to edit YAML files to deploy your Kubernetes app
- Configure an existing app to run on Cloud Code
- Enable Cloud APIs and client libraries
- Manage secrets with Secret Manager
For more Cloud Code tutorials and resources, check out Awesome Cloud Code!
We want to hear your feedback!
The Cloud Code team is inviting our user community to sign-up to participate in Google User Experience Research.
If you’re invited to join a study, you may try out a new product or tell us what you think about the products you use every day. At this time, Google is only sending invitations for upcoming remote studies. Once a study is complete, you’ll receive a token of thanks for your participation such as a gift card or some Google swag.
Sign up using this link and answer a few questions about yourself, as this will help our research team match you to studies that are a great fit.
