Day24-DIY总是比较麻烦 如何建立chart

在上一章我们使用的仓库内的chart,这章後面会介绍怎麽建立自己的chart,不过在建立自己的的chart前,可以看看是否已经有线上写好的版本,这时你就需要透过指令寻找chart。

search chart

当你想要寻找特定chart时,可以透过search指令来寻找chart,

    helm search hub

或者

    helm search repo

这两者的差别在於 search hub 是去Artifact hub 找寻chart。
如下图:
https://ithelp.ithome.com.tw/upload/images/20211002/20129607TKMr3JtJOB.png
helm search repo则是搜寻你加到本机repo的chart(用helm repo add)加到本机的。
如下图:
https://ithelp.ithome.com.tw/upload/images/20211002/20129607hg5vhwnF6R.png

可以看到从线上的Artifact hub找到的chart比我们当初加入到本地repo的chart多上很多,如果只是单纯要找chart的话,可以用search hub去寻找即可。
如果你看了线上的chart都没有你要的,就可以建立一个自己的chart。

建立chart

要建立自己的chart,可以透过helm create指令:

    helm create nginx-demo

他会建出像下图的目录:
https://ithelp.ithome.com.tw/upload/images/20211002/20129607J7OI3nPw9M.png

打开deployment.yaml,可以看到他出现下面这种格式:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ include "nginx-demo.fullname" . }}
  labels:
    {{- include "nginx-demo.labels" . | nindent 4 }}
spec:
  {{- if not .Values.autoscaling.enabled }}
  replicas: {{ .Values.replicaCount }}
  {{- end }}
  selector:
    matchLabels:
      {{- include "nginx-demo.selectorLabels" . | nindent 6 }}
  template:
    metadata:
      {{- with .Values.podAnnotations }}
      annotations:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      labels:
        {{- include "nginx-demo.selectorLabels" . | nindent 8 }}
    spec:
      {{- with .Values.imagePullSecrets }}
      imagePullSecrets:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      serviceAccountName: {{ include "nginx-demo.serviceAccountName" . }}
      securityContext:
        {{- toYaml .Values.podSecurityContext | nindent 8 }}
      containers:
        - name: {{ .Chart.Name }}
          securityContext:
            {{- toYaml .Values.securityContext | nindent 12 }}
          image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
          imagePullPolicy: {{ .Values.image.pullPolicy }}
          ports:
            - name: http
              containerPort: 80
              protocol: TCP
          livenessProbe:
            httpGet:
              path: /
              port: http
          readinessProbe:
            httpGet:
              path: /
              port: http
          resources:
            {{- toYaml .Values.resources | nindent 12 }}
      {{- with .Values.nodeSelector }}
      nodeSelector:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      {{- with .Values.affinity }}
      affinity:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      {{- with .Values.tolerations }}
      tolerations:
        {{- toYaml . | nindent 8 }}
      {{- end }}

上图当中可看到不少.Values.replicaCount这种格式的设定,这时打开values.yaml
直接搜寻replicaCount,可以找到这个

replicaCount: 1

这边代表当你使用helm installhelm update时,就会使用values.yaml内设定的数值。不过,如果要让不同站别使用不同设定,还需要别的处理方式,这部分会留到下一章讲解。


<<:  股市/程序交易

>>:  Day24-Go Json处理

【day5】二林&员林特色小吃

疫情前期看到千千拍摄《我们回家吧》系列 刚好跟男友回员林 所以就照着千千的推荐名单走一次罗 阳光老店...

第51天~

这个得上一篇:https://ithelp.ithome.com.tw/articles/10259...

椭圆曲线数字签名算法 (Elliptic Curve Digital Signature Algorithm:ECDSA)

椭圆曲线数字签名算法 (ECDSA) 是FIPS 186-4批准的合法数字签名算法。这意味着 ECD...

Vuex 是什麽

Vuex 是 Vue 提供的一种资料状态管理的模式,它可以统一控管资料的状态,都是在小型的 SPA ...

Day12-Webhook 实作(一)LINEBot Channel 申请、SDK 安装

大家好~ 接下来就用 LINEBot 当我们 Webhook 的实作练习吧! Channel 申请 ...