Creating a Deployment

Since our backend API is a stateless application, we don't need to deploy a StatefulSet like we did with Elasticsearch. We can simply use a simpler Kubernetes Object that we've encountered already—Deployment.

Create a new manifest at manifests/backend/deployment.yaml with the following content:

apiVersion: apps/v1kind: Deploymentmetadata:  name: backend  labels:    app: backendspec:  selector:    matchLabels:      app: backend  replicas: 3  template:    metadata:      labels:        app: backend    spec:      containers:      - name: backend        image: d4nyll/hobnob:0.1.0        ports:        - containerPort: 8080          name: api        - containerPort: 8100          name: docs        env:        - name: ELASTICSEARCH_HOSTNAME          value: "http://elasticsearch"        - name: ELASTICSEARCH_PORT          value: "9200"        ...

For the .spec.template.spec.containers[].env ...

Get Building Enterprise JavaScript Applications 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.