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", ...

Get Docker and Kubernetes for Java Developers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.