O'Reilly logo

Docker and Kubernetes for Java Developers by Jaroslaw Krochmalski

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating a service using the API

First, let's create a service manifest file. Note that if you have your services, deployments, and Pods created in Chapter 8, Using Kubernetes with Java, by using the kubectl, you will need to delete them using kubectl or the Kubernetes dashboard. We are going to use the same names for the service and a deployment. When using curl with larger payloads, it's more convenient to have the payload in the external file and not type it in the command-line. The JSON file that we will use as the payload is very similar to the one we have been using when creating a Pod with kubectl, but in JSON format this time. Let's create a file named service.json:

{  "apiVersion": "v1",  "kind": "Service",  "metadata": { "name": "rest-example", ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required