k8s – google 產生 node 方式

google 產生 node 方式

google 產生 node 方式

  1. 產生 node 機器(共三台),到 gcp (kubernetes engine) → 新增節點集區→ 填名稱→節點調整為 1 → 調整 cpu x2 ram 4G → 管理 關閉啟用自動升級功能/以及啟用自動修復功能

  2. 到 devops-k8s-prod/geo1~x/底下編輯 deploy.yml and service.yml
    deploy.yml 修改  
    有關 name: geo1 (要改的名稱) and nodeSelector: geo-slave-node-1 對應

    apiVersion: extensions/v1beta1
    kind: Deployment
    metadata:
      name: geo1
    spec:
      replicas: 1
      strategy:
        type: RollingUpdate
        rollingUpdate:
          maxSurge: 1
          maxUnavailable: 1
      minReadySeconds: 5
      template:
        metadata:
          labels:
            name: geo1
            env: production
            color: blue
        spec:
          hostNetwork: false
          nodeSelector:
            cloud.google.com/gke-nodepool: geo-slave-node-1
          containers:
          - name: geo1
            image: asia.gcr.io/-174006/geo:v0.6.1
            imagePullPolicy: Always
            ports:
            - containerPort: 8106
  3. 修改完執行 kubectl apply -f deploy.yml 。請看 pod 是否正常
    kubectl get pod | grep geo (deploy.yml)
    geo-b8d87f6dd-fktwr                          1/1     Running       0          18d
    geo-blue-74ffc77f69-vj8gl                    1/1     Running       0          17d
    geo1-78754b7f8b-tzbkg                        1/1     Running       0          174m
    geo2-5d6f8d8cc5-m698v                        1/1     Running       0          25m
    geo3-7ccf7594bd-vzd79                        1/1     Running       0          25m
    geo4-555f974fdf-lscmt                        1/1     Running       0          156
  4. service.yml 修改
    有關 name: geo1 (要改的名稱)
    apiVersion: v1
    kind: Service
    metadata:
      name: geo1
    spec:
      type: NodePort
      ports:
        - name: geo1
          protocol: TCP
          port: 8106
          targetPort: 8106
      selector:
        name: geo1
        env: production
        color: blue
  5. 修改完執行 kubectl apply -f service.yml 。請看 pod 是否正常
    kubectl get service | grep geo
    geo                   NodePort       10.23.241.223               8106:31422/TCP                                 622d
    geo-blue              NodePort       10.23.253.176               8106:31244/TCP                                 31d
    geo1                  NodePort       10.23.246.55                8106:31259/TCP                                 172m
    geo2                  NodePort       10.23.244.199               8106:31907/TCP                                 12d
    geo3                  NodePort       10.23.247.234               8106:30136/TCP                                 20h
    geo4                  NodePort       10.23.248.128               8106:32107/TCP                                 146m
  6.  登入 kong → APIS → 修改NAME geo-for test → Uris /geo1/v1 → https://geo1:8106
    測試是否正常運作
    https://api.xxxxx.com/geo1/v1/get_geo_info/?ip=115.178.180.42&apikey=ywhYbFyanJIr0q9xeJezgU884STJpoxu
  7. 確認沒問題,加入 upstreams → geos DETAILS → Targets → 把 geo1 內網ip加進去