Google Associate Cloud Engineer Question 209
Select 2Google Cloud PlatformYou are managing a Google Kubernetes Engine (GKE) cluster and want to deploy a new application using a Deployment resource. The application requires 3 replicas and needs to be exposed to the internet. Which of the following steps should you take to achieve this?
- A
Create a Deployment YAML file specifying 3 replicas and apply it using kubectl apply.
- B
Run kubectl create deployment with the --replicas=3 flag.
- C
Create a Service of type LoadBalancer to expose the Deployment to the internet.
- D
Create a Network Endpoint Group to expose the Deployment to the internet.
- E
Use kubectl expose to create a Service of type ClusterIP.
Show answer and explanation
Correct answers: A, C
Explanation
To deploy an application on GKE with 3 replicas and expose it to the internet, you can create a Deployment with the specified replicas and a LoadBalancer Service to handle external traffic. The LoadBalancer Service automatically provisions an external IP, making the application accessible from the internet.
- A. Correct.
Creating a Deployment YAML file and applying it using kubectl apply is a common way to define and manage Kubernetes resources declaratively, including setting the number of replicas.
- B. Incorrect.
Using kubectl create deployment with the --replicas=3 flag is another way to create a Deployment, but this command alone doesn't expose the application to the internet.
- C. Correct.
Creating a Service of type LoadBalancer is the recommended way to expose an application running on GKE to the internet, as it provisions an external IP address.
- D. Incorrect.
A Network Endpoint Group is related to Google Cloud's load balancing but is not directly used to expose Kubernetes applications.
- E. Incorrect.
Using kubectl expose with type ClusterIP exposes the application within the cluster, not to the internet.