In this section we would go through the microservices application and deploy the application on the Kubernetes Cluster.
- Download the project from GitHub.
git clone https://github.com/navveenbalani/google-cloud-kubernetes-secure-e2e.git
- Go to the google-cloud-kubernetes-secure-e2e microservice folder. Our microservice comprises of these simple services listed in server.js – echo, healthz, and fecthWebsite.
Echo service listens over POST and sends the request message back as a response:
app.post('/echo', (req, res) => {
res
.status(200)
.json({message: req.body.message})
.end();
});
The healthz service provides a health status for our services. A Service exposed through an Ingress must respond to health checks from the load balancer. We would specify this URL in the readinessProbe configuration while deploying our service.
The fetchWebsite tests out external connectivity from our private Kubernetes cluster. This basically checks if Cloud NAT is configured properly.
app.get('/fetchWebsite', (req, res) => {
request('https://navveenbalani.dev/', function (error, response, html) {
if (!error && response.statusCode == 200) {
res
.status(200)
.json({message: "ok"})
.end();
} else {
res
.status(500)
.json({message: error})
.end();
}
})
});
You can deploy your own microservices application but add healthz (or a similar health checkup service) to indicate that the service is healthy and ready.