helm hook安装后shell脚本执行
我试图设置舵“后安装”挂钩,并看到下面的错误。 错误: sh:script/jenkins.sh:未找到 postinstall.yaml内容helm hook安装后shell脚本执行,sh,hook,kubernetes-helm,Sh,Hook,Kubernetes Helm,我试图设置舵“后安装”挂钩,并看到下面的错误。 错误: sh:script/jenkins.sh:未找到 postinstall.yaml内容 apiVersion: batch/v1 kind: Job metadata: name: "{{ .Release.Name }}" annotations: # This is what defines this resource as a hook. Without this line, the # j
apiVersion: batch/v1
kind: Job
metadata:
name: "{{ .Release.Name }}"
annotations:
# This is what defines this resource as a hook. Without this line, the
# job is considered part of the release.
"helm.sh/hook": post-install
"helm.sh/hook-weight": "-5"
spec:
template:
spec:
containers:
- name: post-install-jenkins-job
image: alpine:3.3
imagePullPolicy: IfNotPresent
command: [ "/bin/sh", "-c", "scripts/jenkins.sh"]
restartPolicy: Never
terminationGracePeriodSeconds: 0
helm封装的文件夹结构
scripts/jenkins.h是我试图用“postinstall.yaml”作为安装后helm钩子执行的脚本
riq-agent
├── Chart.yaml
├── README.md
├── scripts
│ └── jenkins.sh
├── templates
│ ├── NOTES.txt
│ ├── Untitled-1.yml
│ ├── _helpers.tpl
│ ├── awssecret.yaml
│ ├── clusterrolebinding.yaml
│ ├── configurationFiles-configmap.yaml
│ ├── deployment.yaml
│ ├── hook-aws-ecr.yaml
│ ├── initializationFiles-configmap.yaml
│ ├── postinstall.yaml
│ ├── pvc.yaml
│ ├── secrets.yaml
│ ├── serviceaccount.yaml
│ ├── servicemonitor.yaml
│ ├── svc.yaml
│ └── tests
│ ├── test-configmap.yaml
│ └── test.yaml
└── values.yaml
我试图在helm hook中执行shell脚本(存储在helm包中)的方式是否有任何错误?为了执行,脚本/jenkins.sh应该是安装后jenkins作业容器的一部分,作为卷装入。你可以 安装后配置映射.yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Release.Name }}-postinstall-configmap
data:
jenkins.sh: |-
{{ .Files.Get "scripts/jenkins.sh" | indent 4}}
apiVersion: batch/v1
kind: Job
metadata:
name: "{{ .Release.Name }}"
annotations:
"helm.sh/hook": post-install
"helm.sh/hook-weight": "-5"
spec:
template:
spec:
containers:
- name: post-install-jenkins-job
image: alpine:3.3
imagePullPolicy: IfNotPresent
command: [ "/bin/sh", "-c", "/opt/scripts/jenkins.sh"]
volumeMounts:
- name: config-volume
mountPath: /opt/scripts
volumes:
- name: config-volume
configMap:
name: {{ .Release.Name }}-postinstall-configmap
defaultMode: 0777
restartPolicy: Never
terminationGracePeriodSeconds: 0
postinstall.yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Release.Name }}-postinstall-configmap
data:
jenkins.sh: |-
{{ .Files.Get "scripts/jenkins.sh" | indent 4}}
apiVersion: batch/v1
kind: Job
metadata:
name: "{{ .Release.Name }}"
annotations:
"helm.sh/hook": post-install
"helm.sh/hook-weight": "-5"
spec:
template:
spec:
containers:
- name: post-install-jenkins-job
image: alpine:3.3
imagePullPolicy: IfNotPresent
command: [ "/bin/sh", "-c", "/opt/scripts/jenkins.sh"]
volumeMounts:
- name: config-volume
mountPath: /opt/scripts
volumes:
- name: config-volume
configMap:
name: {{ .Release.Name }}-postinstall-configmap
defaultMode: 0777
restartPolicy: Never
terminationGracePeriodSeconds: 0