페이지

2019년 11월 20일 수요일

Microservice deployment to Kubernetes

https://github.com/karthequian/wishlist

# Deploying our application to Kubernetes

We're ready to deploy our application to Kubernetes, but let's take a look at our assets.

## Goals:
1. View our sample application and containers
2. Take a look at our deployment file
3. Take a look at our alternate deployment file
4. Deploy our application into kubernetes and verify we can see our API's working.

## Goal 1
View the sample application here:

## Goal 2
To view the deployment file, take a look at wishlist-deployment.yaml

## Goal 3
To see another way to run the microservices, take a look at wishlist-deployment-alernate.yaml

## Goal 4
To run the microservice described in goal #1, from the current directory, run:

`kubectl create -f wishlist-deployment.yaml`

To verify that the deployment is online:
`kubectl get deployments`

To verify that the replica sets are running:
`kubectl get rs`

To verify that the pods are running:
`kubectl get pods`

To see the services:
`kubectl get services`

To interact with your API's in the minikube environment:
`minikube service wishlist-service`



# Wishlist deployment yaml
kind: Deployment
apiVersion: apps/v1
metadata:
  name: wishlist-deployment
  labels:
    app: wishlist
spec:
  replicas: 3 #We always want more than 1 replica for HA
  selector:
    matchLabels:
      app: wishlist
  template:
    metadata:
      labels:
        app: wishlist
    spec:
      containers:
      - name: wishlist #1st container
        image: karthequian/wishlist:1.0 #Dockerhub image
        ports:
        - containerPort: 8080 #Exposes the port 8080 of the container
        env:
        - name: PORT #Env variable key passed to container that is read by app
          value: "8080" # Value of the env port.
      - name: catalog #2nd container
        image: karthequian/wishlist-catalog:1.0
        ports:
        - containerPort: 8081
        env:
        - name: PORT
          value: "8081"
      - name: auth #3rd container
        image: karthequian/wishlist-auth:1.0
        ports:
        - containerPort: 8082
        env:
        - name: PORT
          value: "8082"
---
kind: Service
apiVersion: v1
metadata:
  name: wishlist-service
  namespace: default
spec:
  type: NodePort
  selector:
    app: wishlist
  ports:
  - name: wishlist-port
    protocol: TCP
    port: 8080
  - name: wishlist-auth-port
    protocol: TCP
    port: 8081
  - name: wishlist-catalog-port
    protocol: TCP
    port: 8082



댓글 없음: