elgris/microservice-app-example

Kubernetes deployment manifest is outdated

nav9 opened this issue · 1 comments

nav9 commented

When I run $ kubectl create -R -f k8s/, I get the output:

service/auth-api created
service/frontend created
service/redis-queue created
service/todos-api created
service/users-api created
service/zipkin created
unable to recognize "k8s/auth-api/deployment.yaml": no matches for kind "Deployment" in version "extensions/v1beta1"
unable to recognize "k8s/frontend/deployment.yaml": no matches for kind "Deployment" in version "extensions/v1beta1"
unable to recognize "k8s/log-message-processor/deployment.yaml": no matches for kind "Deployment" in version "extensions/v1beta1"
unable to recognize "k8s/redis-queue/deployment.yaml": no matches for kind "Deployment" in version "extensions/v1beta1"
unable to recognize "k8s/todos-api/deployment.yaml": no matches for kind "Deployment" in version "extensions/v1beta1"
unable to recognize "k8s/users-api/deployment.yaml": no matches for kind "Deployment" in version "extensions/v1beta1"
unable to recognize "k8s/zipkin/deployment.yaml": no matches for kind "Deployment" in version "extensions/v1beta1"

The yaml files need to be updated to apps/v1 format, as mentioned here: https://stackoverflow.com/questions/58481850/no-matches-for-kind-deployment-in-version-extensions-v1beta1

kubectl version
Client Version: version.Info{Major:"1", Minor:"21", GitVersion:"v1.21.3", GitCommit:"ca643a4d1f7bfe34773c74f79527be4afd95bf39", GitTreeState:"clean", BuildDate:"2021-07-15T21:04:39Z", GoVersion:"go1.16.6", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"21", GitVersion:"v1.21.2", GitCommit:"092fbfbf53427de67cac1e9fa54aaa09a28371d7", GitTreeState:"clean", BuildDate:"2021-06-16T12:53:14Z", GoVersion:"go1.16.5", Compiler:"gc", Platform:"linux/amd64"}
nav9 commented

I'm posting the updated yaml files in apps/v1 format:

AuthAPI:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: auth-api
  labels:
    app: microservice-app-example
spec:
  replicas: 1
  selector:
    matchLabels:
        any-name: auth-api
  template:
    metadata:
      labels:
        app: microservice-app-example
        any-name: auth-api
    spec:
      containers:
      - env:
        - name: AUTH_API_PORT
          value: "8081"
        - name: JWT_SECRET
          value: myfancysecret
        - name: USERS_API_ADDRESS
          value: http://users-api:8083
        - name: ZIPKIN_URL
          value: http://zipkin:9411/api/v2/spans          
        image: auth-api
        name: auth-api
        ports:
        - containerPort: 8081
        imagePullPolicy: Never
      restartPolicy: Always
      
---
apiVersion: v1
kind: Service
metadata:
  labels:
    app: microservice-app-example
  name: auth-api
spec:

  ports:
  - targetPort: 8081
    port: 8081
  selector:
    any-name: auth-api 

Frontend:

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: microservice-app-example
  name: frontend
spec:
  replicas: 1
  selector:
    matchLabels:
        any-name: frontend
  template:
    metadata:
      labels:
        app: microservice-app-example
        any-name: frontend
    spec:
      containers:
      - env:
        - name: AUTH_API_ADDRESS
          value: http://auth-api:8081
        - name: PORT
          value: "8080"
        - name: TODOS_API_ADDRESS
          value: http://todos-api:8082
        - name: ZIPKIN_URL
          value: http://zipkin:9411/api/v2/spans
        image: frontend
        name: frontend
        ports:
        - containerPort: 8080
        imagePullPolicy: Never
      restartPolicy: Always
---
apiVersion: v1
kind: Service
metadata:
  labels:
    app: microservice-app-example
  name: frontend
spec:
  ports:
  - port: 8080
  selector:
    service: frontend
#  type: LoadBalancer    

Log message processor:

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: microservice-app-example
  name: log-message-processor
spec:
  replicas: 1
  selector:
    matchLabels:
        any-name: log-message-processor
  template:
    metadata:
      labels:
        app: microservice-app-example
        any-name: log-message-processor
    spec:
      containers:
      - env:
        - name: REDIS_HOST
          value: redis-queue
        - name: REDIS_PORT
          value: "6379"
        - name: REDIS_CHANNEL
          value: log_channel
        - name: ZIPKIN_URL
          value: http://zipkin:9411/api/v1/spans
          
        image: log-message-processor
        name: log-message-processor
        imagePullPolicy: Never
      restartPolicy: Always

Redis queue:

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: microservice-app-example
  name: redis-queue
spec:
  replicas: 1
  selector:
    matchLabels:
        any-name: redis-queue
  template:
    metadata:
      labels:
        app: microservice-app-example
        any-name: redis-queue
    spec:
      containers:
      - env:
        image: redis
        name: redis-queue
        ports:
        - containerPort: 6379
      restartPolicy: Always
---
apiVersion: v1
kind: Service
metadata:
  labels:
    app: microservice-app-example
  name: redis-queue
spec:
  ports:
  - port: 6379
  selector:
    any-name: redis-queue  

Todo's API:

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: microservice-app-example
  name: todos-api
spec:
  replicas: 1
  selector:
    matchLabels:
        any-name: todos-api 
  template:
    metadata:
      labels:
        app: microservice-app-example
        any-name: todos-api
    spec:
      containers:
      - env:
        - name: JWT_SECRET
          value: myfancysecret
        - name: TODO_API_PORT
          value: "8082"
        - name: REDIS_HOST
          value: redis-queue
        - name: REDIS_PORT
          value: "6379"
        - name: REDIS_CHANNEL
          value: log_channel
        - name: ZIPKIN_URL
          value: http://zipkin:9411/api/v2/spans
          
        image: todos-api
        name: todos-api
        ports:
        - containerPort: 8082
        imagePullPolicy: Never
      restartPolicy: Always
---
apiVersion: v1
kind: Service
metadata:
  labels:
    app: microservice-app-example
  name: todos-api
spec:
  ports:
  - port: 8082
  selector:
    any-name: todos-api     

Users API:

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: microservice-app-example
  name: users-api
spec:
  replicas: 1
  selector:
    matchLabels:
        any-name: users-api
  template:
    metadata:
      labels:
        app: microservice-app-example
        any-name: users-api
    spec:
      containers:
      - env:
        - name: JWT_SECRET
          value: myfancysecret
        - name: SERVER_PORT
          value: "8083"
        - name: SPRING_ZIPKIN_BASE_URL
          value: http://zipkin:9411
        image: users-api
        name: users-api
        ports:
        - containerPort: 8083
        imagePullPolicy: Never
      restartPolicy: Always
---
apiVersion: v1
kind: Service
metadata:
  labels:
    app: microservice-app-example
  name: users-api
spec:
  ports:
  - port: 8083
  selector:
    any-name: users-api    

Zipkin:

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: microservice-app-example
  name: zipkin
spec:
  replicas: 1
  selector:
    matchLabels:
        any-name: zipkin
  template:
    metadata:
      labels:
        app: microservice-app-example
        any-name: zipkin
    spec:
      containers:
      - env:
        image: openzipkin/zipkin
        name: zipkin
        ports:
        - containerPort: 9411
        - containerPort: 9410
      restartPolicy: Always
---
apiVersion: v1
kind: Service
metadata:
  labels:
    app: microservice-app-example
  name: zipkin
spec:
  ports:
  - port: 9411
  selector:
    any-name: zipkin
#  type: LoadBalancer