K8S Deployment & Service Objects

Step 1 of 3

Step 1 - Create a Deployment

You can create and manage a Deployment by using the Kubernetes command line interface, Kubectl. When you create a Deployment, you'll need to specify the container image for your application and the number of replicas that you want to run.

Katas

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: carts-db
  labels:
    name: carts-db
    ##namespace : YOUR_CONTEXT_NAMESPACE
spec:
  replicas: 1
  template:
    metadata:
      labels:
        name: carts-db
    spec:
      containers:
      - name: carts-db
        image: mongo
        ports:
        - name: mongo
          containerPort: 27017
        securityContext:
          capabilities:
            drop:
              - all
            add:
              - CHOWN
              - SETGID
              - SETUID
        volumeMounts:
        - mountPath: /tmp
          name: tmp-volume
      volumes:
        - name: tmp-volume
          emptyDir:
            medium: Memory
      nodeSelector:
        beta.kubernetes.io/os: linux

Copy and paste to cartsdb-deployment.yml the file

To create a deployment kubectl create -f cartsdb-deployment.yml.

To check your deployment status kubectl get deployment.

cartsdb-deployment.yml
cartsdb-service.yml
sockshop-deployment.yml
sockshop-service.yml