如何在头盔中修复Error: must either provide a name or specify --generate-name
将示例舵图名称创建为mychart,并使用nginx服务编写了deployment.yaml,service.yaml,ingress.yaml。之后,运行$ helm之类的命令,安装mychart
apiVersion: v1
kind: Service
metadata:
name: nginx
spec:
ports:
- name: main
port: 80
protocol: TCP
targetPort: 80
selector:
app: nginx
apiVersion: extensions/v1beta2
kind: Deployment
metadata:
name: nginx
spec:
replicas: 3
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.13
ports:
containerPort: 80
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: nginx
annotations:
http.port: "443"
spec:
backend:
serviceName: nginx
servicePort: 80
预期输出:
.....
status: DEPLOYED
答案 0 :(得分:16)
在头盔v3中,您可以使用以下任一方式:
helm install [NAME] [CHART]
或:
helm install [CHART] --generate-name
示例:
helm install reloader stakater/reloader
helm install stakater/reloader --generate-name
从帮助手册:
helm install --help
Usage:
helm install [NAME] [CHART] [flags]
Flags:
-g, --generate-name generate the name (and omit the NAME parameter)
答案 1 :(得分:10)
根据v3.x的Helm文档
helm install --help
Usage:
helm install [NAME] [CHART] [flags]
您要使用的:
掌舵安装“您的发行名称”图表
例如:
# helm repo add stable https://kubernetes-charts.storage.googleapis.com/
# helm install wordpress-helm-testing stable/wordpress
NAME: wordpress-helm-testing
LAST DEPLOYED: 2019-10-07 15:56:21.205156 -0700 PDT m=+1.763748029
NAMESPACE: default
STATUS: deployed
NOTES:
1. Get the WordPress URL:
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
Watch the status with: 'kubectl get svc --namespace default -w wordpress-helm-testing'
export SERVICE_IP=$(kubectl get svc --namespace default wordpress-helm-testing --template "{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}")
echo "WordPress URL: http://$SERVICE_IP/"
echo "WordPress Admin URL: http://$SERVICE_IP/admin"
2. Login with the following credentials to see your blog
echo Username: user
echo Password: $(kubectl get secret --namespace default wordpress-helm-testing -o jsonpath="{.data.wordpress-password}" | base64 --decode)
#helm list
NAME NAMESPACE REVISION UPDATED STATUS CHART
wordpress-helm-testing default 1 2019-10-07 15:56:21.205156 -0700 PDT deployed wordpress-7.3.9
这是一种更好的操作方法,因为它消除了发行版名称中的随机性。您可能想要使用诸如用户名之类的东西,或者使它唯一的东西,并且为GUID之外的版本增加含义,--generate-name选项将为您提供。
答案 2 :(得分:2)
只需在--generate-name
命令的末尾添加helm
答案 3 :(得分:0)
假设图表在当前目录中:
helm install some-name。
输出:
NAME: some-name
LAST DEPLOYED: Sun Jan 5 21:03:25 2020
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None
答案 4 :(得分:0)