我使用helm create命令创建了基本的helm模板.在检查Ingress的模板时,它会像这样添加字符串RELEASE-NAME和appnameRELEASE-NAME-microapp
我怎样才能改变.Release.Name价值?
helm template --kube-version 1.11.1 microapp/
# Source: microapp/templates/ingress.yaml
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: RELEASE-NAME-microapp
labels:
app: microapp
chart: microapp-0.1.0
release: RELEASE-NAME
heritage: Tiller
annotations:
kubernetes.io/ingress.class: nginx
Run Code Online (Sandbox Code Playgroud) 最近,prometheus-operator已提升为稳定舵图(https://github.com/helm/charts/tree/master/stable/prometheus-operator)。
我想了解如何通过k8s集群中的prometheus-operator将自定义应用程序添加到监视中。例如,默认情况下会在9252上提供指标的gitlabRunner示例将不胜感激(https://docs.gitlab.com/runner/monitoring/#configuration-of-the-metrics-http-server)。
我有一个基本的YAML这显然是行不通的,但也没有提供任何反馈什么是不工作:
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: gitlab-monitor
# Change this to the namespace the Prometheus instance is running in
namespace: default
labels:
app: gitlab-runner-gitlab-runner
release: prometheus
spec:
selector:
matchLabels:
app: gitlab-runner-gitlab-runner
namespaceSelector:
# matchNames:
# - default
any: true
endpoints:
- port: http-metrics
interval: 15s
Run Code Online (Sandbox Code Playgroud)
这是prometheus配置:
> kubectl get prometheus -o yaml
...
serviceMonitorNamespaceSelector: {}
serviceMonitorSelector:
matchLabels:
release: prometheus
...
Run Code Online (Sandbox Code Playgroud)
因此,选择器应该匹配。“不工作”是指端点不会出现在Prometheus UI中。
我试图改变一个变量的值,如果它设置的另一个变量是通过将两个变量组合在中间的一个短划线,我不确定这样做的语法,我想到的事情如下:
{{- $serviceNamespace := .Values.serviceNamespace -}}
{{- $serviceTag := .Values.serviceTag -}}
{{- if $serviceTag}}
{{- $serviceNamespace := .Values.serviceNamespace "-" .Values.serviceTag -}}
{{- end}}
Run Code Online (Sandbox Code Playgroud)
它是否正确?如果serviceNamespace是hello,serviceTag那1.0.0我最终会serviceNamespace成为hello-1.0.0?
我有一个包含以下条目的docker compose文件
version: '2.1'
services:
mysql:
container_name: mysql
image: mysql:latest
volumes:
- ./mysqldata:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: 'password'
ports:
- '3306:3306'
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3306"]
interval: 30s
timeout: 10s
retries: 5
test1:
container_name: test1
image: test1:latest
ports:
- '4884:4884'
- '8443'
depends_on:
mysql:
condition: service_healthy
links:
- mysql
Run Code Online (Sandbox Code Playgroud)
Test-1容器依赖于mysql,并且需要启动并运行。
在docker中,可以使用运行状况检查和Depends_on属性来控制它。kubernetes中的运行状况检查等效项是我已经创建的readinessprobe,但是我们如何控制吊舱中容器的启动?
任何方向对此表示极大的赞赏。
我的Kubernetes文件:
apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: deployment
spec:
replicas: 1
template:
metadata:
labels:
app: deployment
spec:
containers:
- name: mysqldb
image: "dockerregistry:mysqldatabase"
imagePullPolicy: Always
ports:
- containerPort: 3306 …Run Code Online (Sandbox Code Playgroud) 我已经安装了redis. 我的默认名字是plinking-narwhal. 现在我想用我指定的名称安装一个服务。但首先我想删除现有的。我曾尝试删除它们但没有成功。
$ kubectl get all
NAME READY STATUS RESTARTS AGE
pod/plinking-narwhal-redis-master-0 1/1 Running 0 12m
pod/plinking-narwhal-redis-slave-9b645b597-2vh82 1/1 Running 7 12m
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 15m
service/plinking-narwhal-redis-master ClusterIP 10.109.186.189 <none> 6379/TCP 12m
service/plinking-narwhal-redis-slave ClusterIP 10.99.122.12 <none> 6379/TCP 12m
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
deployment.apps/plinking-narwhal-redis-slave 1 1 1 1 12m
NAME DESIRED CURRENT READY AGE
replicaset.apps/plinking-narwhal-redis-slave-9b645b597 1 1 1 12m
NAME DESIRED CURRENT AGE
statefulset.apps/plinking-narwhal-redis-master 1 1 12m …Run Code Online (Sandbox Code Playgroud) 我正在使用 Helm 3 和 microk8s。当我尝试试运行时:
microk8s.helm install <...> --dry-run --debug
Run Code Online (Sandbox Code Playgroud)
我看到类似的错误
Error: YAML parse error on ./templates/deployment.yaml: error converting YAML to JSON: yaml: mapping values are not allowed in this context
helm.go:76: [debug] error converting YAML to JSON: yaml: mapping values are not allowed in this context
YAML parse error on ./templates/deployment.yaml
helm.sh/helm/v3/pkg/releaseutil.(*manifestFile).sort
/home/circleci/helm.sh/helm/pkg/releaseutil/manifest_sorter.go:129
helm.sh/helm/v3/pkg/releaseutil.SortManifests
/home/circleci/helm.sh/helm/pkg/releaseutil/manifest_sorter.go:98
helm.sh/helm/v3/pkg/action.(*Configuration).renderResources
/home/circleci/helm.sh/helm/pkg/action/install.go:455
helm.sh/helm/v3/pkg/action.(*Install).Run
/home/circleci/helm.sh/helm/pkg/action/install.go:214
main.runInstall
...
Run Code Online (Sandbox Code Playgroud)
我发现了几个有类似错误的问题,但答案通常只是要求读取图表代码。我有一个很大的图表,需要自己调试这个错误。猜测它抱怨哪一行似乎没有意义。
有没有办法知道配置中究竟有什么问题?
尝试安装 helm 但收到如下错误消息:
install.go:178: [debug] Original chart version: ""
install.go:195: [debug] CHART PATH: /Users/lkkto/Dev/pipelines/manifests/helm/helm-pipeline/charts/base/charts/installs/charts/multi-user/charts/api-service
client.go:128: [debug] creating 4 resource(s)
Error: INSTALLATION FAILED: ConfigMap in version "v1" cannot be handled as a ConfigMap: json: cannot unmarshal bool into Go struct field ConfigMap.data of type string
helm.go:84: [debug] ConfigMap in version "v1" cannot be handled as a ConfigMap: json: cannot unmarshal bool into Go struct field ConfigMap.data of type string
INSTALLATION FAILED
main.newInstallCmd.func2
helm.sh/helm/v3/cmd/helm/install.go:127
github.com/spf13/cobra.(*Command).execute
github.com/spf13/cobra@v1.3.0/command.go:856
github.com/spf13/cobra.(*Command).ExecuteC
github.com/spf13/cobra@v1.3.0/command.go:974
github.com/spf13/cobra.(*Command).Execute
github.com/spf13/cobra@v1.3.0/command.go:902
main.main
helm.sh/helm/v3/cmd/helm/helm.go:83 …Run Code Online (Sandbox Code Playgroud) 使用helminstall可以在安装图表时设置值,如:
helm install --set favoriteDrink=slurm ./mychart
Run Code Online (Sandbox Code Playgroud)
现在想要设置如下值:
helm install --set aws.subnets="subnet-123456, subnet-654321" ./mychart
Run Code Online (Sandbox Code Playgroud)
但失败了:
Error: failed parsing --set data: key " subnet-654321" has no value
Run Code Online (Sandbox Code Playgroud)
似乎helm的--set认识逗号,,并检查下一个字符串作为重点.所以在这种情况下设置这样的字符串时不能使用?
helm install charts/mychart \
--set aws.subnets={subnet-123456,subnet-654321}
Run Code Online (Sandbox Code Playgroud)
得到错误:
Error: This command needs 1 argument: chart name
Run Code Online (Sandbox Code Playgroud)
helm install charts/mychart \
--set aws.subnets="subnet-123456\,subnet-654321"
Run Code Online (Sandbox Code Playgroud)
string shell command-line-interface kubernetes kubernetes-helm
我正在尝试使用以下资源创建Helm图表:
这些也是我希望它们部署的顺序.我在部署中放了一个钩子,以便它是安装后的,但是Helm并没有将它视为资源,我必须手动管理它.
Job需要Secret和ConfigMap中的信息,否则我会将其作为预安装钩子.但我不能把所有东西都当成钩子,否则我的版本就无法管理.
有没有人有解决方案或想法能够管理Helm版本中的所有资源并确保在部署开始之前完成作业?
我现在唯一想到的是两个制作两张图表:一张是1-4,第二张是5,这取决于第一张.
kubernetes-helm ×10
kubernetes ×8
coreos ×1
go-templates ×1
kubeadm ×1
kubectl ×1
microk8s ×1
redis ×1
shell ×1
string ×1
yaml ×1