By default, GKE creates services that are used by GKE itself. Those default services are set out here:
- default-http-backend
- kube-dns
- kubernetes
- metrics-server
The next screenshot shows these services in Cloud console, but as those are GKE core services, we should avoid interaction with them unless there is a clear reason to do so. Changing them might result in GKE cluster and workload downtime:
Figure 6.54 – Internal GKE services
Let’s find out how to interact with services in GKE.
Cloud console
In Cloud console, we can view existing services deployed by clicking on the Services & Ingress menu. Once a service is created, we can view it in Cloud console:
Figure 6.55 – Service visible in Services & Ingress section of GKE
To view service details, you need to click on the service name. In the OVERVIEW section, we can see service details with monitoring.
If we click on the DETAILS tab, we can see trimmed but still helpful information about the service:
Figure 6.56 – Service visible in the Services & Ingress section of GKE
We can see service events, logs, and YAML configuration by clicking on the next tabs.
Command line
Once again, we utilize the kubectl command. This time, we will use the kubectl get services command to display available services:
Figure 6.57 – Listing of services in the existing GKE cluster
To get details of a service, we can use the kubectl describe service YOUR_SERVICENAME command. This results in the following output:
Figure 6.58 – Details of the frontend-5kd5f service by using the kubectl command
The same approach can be used to get details of other service types supported by GKE.
After learning how to view services, we can start creating and utilizing our own services.
As mentioned at the beginning of the Service management section, we can define our services and control how applications can be accessed outside the GKE cluster.
We will combine the command line and Cloud console to add services to the GKE cluster.
Cloud console
First, we need to have the existing application deployed into the GKE cluster. We have the application named frontend prepared to be exposed outside the GKE cluster. Then, proceed as follows:
- To create a service for an existing application, go to Workloads and select your workload.
- From the workload detail, click the ACTIONS button and then Expose:
Figure 6.59 – Internal GKE services
2. We can choose the service type from Cluster IP, Node port, or Load balancer:
Figure 6.60 – Service type selection menu
3. We will choose the Cluster IP default from the selection.
4. Immediately after creation, we can see service metrics, the Cluster IP, and serving Pods:
Figure 6.61 – Cluster IP service details