【问题标题】:How correct change clusterIP to nodeport of kubespray?如何正确将 clusterIP 更改为 kubespray 的 nodeport?
【发布时间】:2018-07-05 10:49:03
【问题描述】:

我尝试使用 kubespray 安装 kubernetes

github repo

在没有编辑器的情况下将 clusterip 更改为 nodeport 命令行

kubectl -n kube-system get service kubernetes-dashboard -o yaml > kube-dash-svc.yaml
sed 's/ClusterIP/NodePort/' kube-dash-svc.yaml > new-kube-dash-svc.yaml
kubectl delete svc kubectl delete svc kubernetes-dashboard --namespace kube-system --namespace kube-system
kubectl create -f new-kube-dash-svc.yaml

安装并将clusterIP更改为nodeport后,我尝试再次安装kubernetes并得到错误:

err='服务 \"kubernetes-dashboard\" 无效:\n* metadata.resourceVersion:无效值:\"\":必须为更新指定\n* spec.clusterIP:无效值:\ "\": 字段不可变\n* spec.ports[0].nodePort: Forbidden: 当type 为'ClusterIP'时不能使用\n'"}

如何正确将clusterIP更改为kubespray的nodeport?

谢谢

【问题讨论】:

    标签: kubernetes


    【解决方案1】:

    ClusterIP 不能简单地通过将 ClusterIP 替换为 NodePort 来更改为 nodeport,因为 ClusterIP 是默认值,所以定义中可能根本没有“ClusterIP”。

    您应该删除所有涉及“clusterIP/ClusterIP”的内容,然后在适当的位置插入“type: NodePort”,例如:

    sed '/clusterIP/d;/ClusterIP/d;/^[ ]*ports:/i \  type: NodePort' 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-14
      • 1970-01-01
      • 1970-01-01
      • 2018-10-29
      • 1970-01-01
      相关资源
      最近更新 更多