Helm Charts
專案需要初始化 Helm Value 使用教學.
Table Of Content
- env => 部屬的環境(必填),可填值 dev devqa intergration staging prod
- type => 部屬的類型(必填),可填值 api job frontend
- dept => 部門的單位(必填),可填值 platform outside interface gt1
- product => 服務名稱(必填),例如: bbchat schedule
- repo => 部屬服務的 repo 名稱(必填),例如: imctl_api, imctl_web
- namespace 預設 default
- serviceAccountName 預設 default
- 服務的名稱(必填)
- container 的資源設置
- hpa 設定,下面有範例(非必填),Utilization 代表使用率,averageValue 代表平均值
- service 設定,讓 pod 可以被外部存取
- secrets,下面有範例
- configmap list,下面有範例
在瀏覽前,若是忘記可以先參考以下文章呦 Helm 簡介
- 在個別的專案根目錄上新增一個資料夾命名為 ”helm_value”
- 到 DevOps / GKE-Helm · GitLab 專案
- 進入 example_value 資料夾中
- 根據專案類型,是 Cronjob 或是 Deployment 類型
- Cronjob 類型選擇 helm_value-cronjob
- Deployment 類型選擇 helm_value-deployment
- 將資料夾中的檔案複製至個別專案上的 helm_value 中
- 全部 yaml 檔案都需要做調整喔
# env => 部屬的環境(必填),可填值 dev devqa intergration staging prod
# type => 部屬的類型(必填),可填值 api job frontend
# dept => 部門的單位(必填),可填值 platform outside interface gt1
# product => 服務名稱(必填),例如: bbchat schedule
# repo => 部屬服務的 repo 名稱(必填),例如: imctl_api, imctl_web
labels:
env: env
type: type
dept: dept
product: product
repo: repo
# namespace 預設 default
namespace: default # service namespace
# serviceAccountName 預設 default
serviceAccountName: null
# 服務的名稱(必填)
name: charles-personal # service name. ex: <部門>-<組別>-<服務名稱>-<服務代號>
deployment:
# container 的屬性
container:
image: nginx:latest # docker image
# Pod 數量
replicaCount: 1
# container 的 command,下面有範例(非必填)
command:
- "/bin/sh"
# container port(非必填)
containerPort: 80
envs:
ref:
configMapRefName: charles-personal-config # ConfigMap Ref
secretRefName: charles-personal-secret # Secret Ref
secretFrom: # Secret value from
envName: TZ
configMapKeyRefName: charles-personal-config
configMapKeyRefKey: TZ
volumes:
name: config
configMap:
name: charles-personal-config
itemsKey: TZ
itemsPath: TZ
volumeMounts:
name: config
mountPath: "/config" # Mount path to access the ConfigMap data. # Python maybe is app/config
# container 的資源設置
resources:
limits:
cpu: "100m"
memory: "128Mi"
requests:
cpu: "100m"
memory: "128Mi"
# hpa 設定,下面有範例(非必填),Utilization 代表使用率,averageValue 代表平均值
hpa:
min: 1
max: 3
metrics:
- type: Resource
resource:
name: cpu
type: Utilization
value: 50
- type: Resource
resource:
name: memory
type: AverageValue
value: 100Mi
# service 設定,讓 pod 可以被外部存取
service:
# service 的 類型 ClusterIP NodePort LoadBalancer
type: "ClusterIP"
# service 的 port,下面有範例
ports:
- name: "http"
port: 80
targetPort: 80
# 白名單
whitelists:
- name: first
ip: 10.0.0.0/24
- name: second
ip: 10.0.2.0/24
ingress:
enabled: false
className: ""
annotations:
{}
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
hosts:
- host: chart-example.local
paths:
- path: /
pathType: Prefix
port: 80
tls: []
# - secretName: chart-example-tls
# hosts:
# - chart-example.local
serviceAccount:
# Specifies whether a service account should be created
create: false
# Automatically mount a ServiceAccount's API credentials?
automount: true
# Annotations to add to the service account
annotations: {}
# The name of the service account to use.
# If not set and create is true, a name is generated using the fullname template
name: ""
# secrets,下面有範例
secrets:
name: charles-personal-secret
data:
TZ: QXNpYS9UYWlwZWk=
# configmap list,下面有範例
configmap:
- name: charles-personal-config
namespace: default
labels:
env: env
type: type
dept: dept
product: product
repo: repo
data:
TZ: "Asia/Taipei"
OBJECT: { FIRST: "first object value", SECOND: "second object value" }
- 接著,執行推 Code 的動作。讓測試碼跑 CI/CD 流程即可
- CI/CD 執行完畢後,到 GKE 上確認服務是否有在線上