我正在为一个项目创建一个图表,该项目具有一个二进制文件,该二进制文件在执行时会生成一个 YAML 格式的配置文件,如下所示:
---
PARAM_1: value1
PARAM_2: value2
Run Code Online (Sandbox Code Playgroud)
我的图表需要读取此文件并将其所有值加载到容器中的环境变量中,因此我config在values.yaml文件中创建了一个变量,当安装图表时,我使用以下方式传递文件内容--set-file:
---
PARAM_1: value1
PARAM_2: value2
Run Code Online (Sandbox Code Playgroud)
接下来我创建一个ConfigMap值为.Values.config:
apiVersion: v1
kind: ConfigMap
metadata:
...
data:
{{ .Values.config }}
Run Code Online (Sandbox Code Playgroud)
我遇到的问题是我需要用 的值做两件事config:
MY_APP_PARAM_1作为键)ConfigMap将失败.Values.config如何将模板中的值解析为 adict以便我可以使用range循环来执行这些更改?
使用 Helm 努力匹配该单词从开始到最后一次出现的情况-。
我尝试过{{- printf "%s" .Release.Name | regexFind "[^-]*$" -}},但它从最后一次出现到单词末尾打印。
预期的
输入:hello-world-here=>输出:hello-world
输入:hello-world-here-and-there=>输出:hello-world-here-and
我想知道是否可以将变量传递给helm install命令的设置参数。以下是我希望实现的目标的示例。
appgw_name = "myappgateway"
export appgw_name
helm install applicationgw application-gateway-kubernetes-ingress/ingress-azure --set appgw.name=$appgw_name
Run Code Online (Sandbox Code Playgroud)
我将上面两行作为 shell 脚本执行,当我尝试执行它们时,出现以下错误:
错误:(ingress-azure/templates/configmap.yaml) 处执行错误:请提供 appgw.applicationGatewayID 或 appgw.name。
jenkins我使用官方 Helm Chart在 GKE 上执行安装。
我最初将插件列表传递给相应的键
- plugin1
- plugin2
- plugin3
- plugin4
Run Code Online (Sandbox Code Playgroud)
并执行helm upgrade --recreate-pods --force --tls --install
然后,我从上面的列表中取出一些插件并helm再次运行相同的命令,例如,
- plugin1
- plugin2
Run Code Online (Sandbox Code Playgroud)
但是,jenkins保留初始列表中的所有插件。
这是预期的行为吗?
这是我的 value.yaml 文件:
options:
collection: "myCollection"
ttl: 100800
autoReconnect: true
reconnectTries: 3
reconnectInterval: 5
Run Code Online (Sandbox Code Playgroud)
现在我尝试在 configMap 中将其转换为 JSON,如下所示:
options: {
{{- range $key, $val := .Values.options }}
{{ $key }}: {{ $val | quote }},
{{- end }}
}
Run Code Online (Sandbox Code Playgroud)
但我需要消除 JSON 中的最后一个逗号,所以我尝试添加一个计数器:
options: {
{{ $c := 0 | int }}
{{- range $key, $val := .Values.options }}
{{ if ne $c 0 }},{{ end }}
{{- $key }}: {{ $val | quote }}
{{ $c := $c add 1 …Run Code Online (Sandbox Code Playgroud) 我正在为一堆部署编写 Helm 图表。我提供的值可以是:
my_value: "/opt/my-path"或者my_value: "/opt/my-path/"
现在我想确保/路径的尽头总是有一个。
我如何使用Go模板来做到这一点?
我有一个 Asp.net Core 项目,我正在尝试使用 Helm 3 创建用于 Kubernetes 部署的 Azure DevOps Pipeline。
该项目的结构是:
服务器图表服务器 Chart.yaml 控制器等。
当前的构建管道会构建 docker 映像,并将其上传到 Azure 容器注册表。
错误发生在 HelmDeploy 任务 'package' => ChartPath:
这是部署的管道阶段:
- stage: 'Deploy'
displayName: 'Deploy the container'
dependsOn: Build
jobs:
- deployment: Deploy
displayName: Deploy
pool:
vmImage: 'ubuntu-latest'
environment: 'staging'
strategy:
runOnce:
deploy:
steps:
- task: HelmInstaller@0
inputs:
helmVersion: 'latest'
installKubectl: true
- task: HelmDeploy@0
inputs:
command: 'package'
chartPath: Server/charts/server
- task: HelmDeploy@0
inputs:
connectionType: 'Kubernetes Service Connection'
kubernetesServiceConnection: 'Staging-592588480'
namespace: 'staging' …Run Code Online (Sandbox Code Playgroud) 我尝试按照ReportPortal 的 kubernetes install README进行操作
guettli@yoga15:~/projects/reportportal-kubernetes/reportportal$ mv v5 reportportal
guettli@yoga15:~/projects/reportportal-kubernetes/reportportal$ helm install ./reportportal
Error: must either provide a name or specify --generate-name
guettli@yoga15:~/projects/reportportal-kubernetes/reportportal$ helm install ./reportportal --generate-name
Error: found in Chart.yaml, but missing in charts/ directory: postgresql, rabbitmq-ha, elasticsearch, minio
Run Code Online (Sandbox Code Playgroud)
这是v5目录。
现在需要做什么?
我正在尝试将 pod 分配到特定节点作为 helm 命令的一部分,因此最终部署 yaml 应该如下所示
spec:
containers:
- name: nginx
image: nginx
imagePullPolicy: IfNotPresent
nodeSelector:
node-name: dev-cpu-pool
Run Code Online (Sandbox Code Playgroud)
我使用此命令作为 Jenkins 文件部署的一部分
`sh "helm upgrade -f charts/${job_name}/default.yaml --set nodeSelector.name=${deployNamespace}-cpu-pool --install ${deployNamespace}-${name} helm/${name} --namespace=${deployNamespace} --recreate-pods --version=${version}`"
Run Code Online (Sandbox Code Playgroud)
部署工作正常,Pod 已启动并运行,但由于某种原因,我无法看到 NodeSelector 键和值作为部署 yaml 的一部分,因此 Pod 未分配给我想要的特定节点。知道出了什么问题吗?我应该将任何占位符作为我的图表模板的一部分还是不是必须的?
在 Azure AKS 上运行 helm 图表打包容器时,我尝试自动注释 pod(编辑:入口控制器 pod),以在 Scalyr 中设置自定义日志解析器。我可以自动注释服务,但无法自动注释 Pod。使用 kubectl 手动执行此操作:
kubectl annotate pod nginx-ingress-ingress-nginx-controller-yyy-xxx --overwrite log.config.scalyr.com/attributes.parser=<my_scalyr_parser_name>
Run Code Online (Sandbox Code Playgroud)
没问题,但是当我的 Pod 终止时,我将丢失注释,并且 Scalyr 可能会丢失一些日志。或者 ingress nginx pod IDDQD(不朽)?所以我正在尝试以某种方式实现自动化。
我尝试将其添加到values.yaml
ingress:
enabled: true
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/use-regex: "true"
log.config.scalyr.com/attributes.parser: "<my_scalyr_parser_name>"
Run Code Online (Sandbox Code Playgroud)
但它只是落在 ingress.yaml 的元数据注释中
kind: Ingress
metadata:
name: {{ $fullName }}
labels:
{{- include "myservice.labels" . | nindent 4 }}
{{- with .Values.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
Run Code Online (Sandbox Code Playgroud)
这会产生服务的注释。但是,我需要在 Pod 上进行注释,以便 Scalyr 使用我的自定义解析器,而不是在服务中。
另一种方法是在安装 nginx-ingress 时硬装:
helm install …Run Code Online (Sandbox Code Playgroud) kubernetes-helm ×10
kubernetes ×5
go-templates ×2
azure ×1
azure-aks ×1
azure-devops ×1
go ×1
jenkins ×1
nginx ×1
regex ×1
reportportal ×1