Creating a deployment using the API

Creating a deployment is very similar to creating a service, it's creating another type of Kubernetes resource, after all. All we need is a proper JSON payload file that we will be sending to the api-server using the POST HTTP method. Our rest-example deployment manifest in JSON can look as follows:

{  "apiVersion": "extensions/v1beta1",  "kind": "Deployment",  "metadata": {    "name": "rest-example"  },  "spec": {    "replicas": 1,    "template": {      "metadata": {        "labels": {          "app": "rest-example",          "tier": "backend"        }      },      "spec": {        "containers": [          {            "name": "rest-example",            "image": "jotka/rest-example",            "imagePullPolicy": "IfNotPresent",            "resources": {              "requests": {                "cpu": "100m",                "memory": "100Mi"              }            },            "env": [              { "name": ...

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.