19.06.2021 Views

148422597X Kubernetes Management Design Patterns [Vohra 2017-01-29] {E559F6BB}

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 3 ■ Kubernetes on Google Cloud Platform

Testing the Kubernetes Cluster

The cluster info may be listed with the following command:

kubectl cluster-info

As shown in Figure 3-59, the Kubernetes master and other cluster components are running.

Figure 3-59. Listing cluster info

Next, we shall create a Node application to test the cluster. Create a folder called hellonode (or some

other folder name). In the hellonode folder create a Node file server.js with the vi editor as shown in

Figure 3-60.

Figure 3-60. Creating a Node script server.js

The Node script server.js responds to any request with the response Hello World!.

var http = require('http');

var handleRequest = function (request, response) {

response.writeHead(200);

response.end('Hello World!');

};

var www = http.createServer(handleRequest);

www.listen(8080);

The server.js is shown in a vi editor in Figure 3-61.

81

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!