<p>I try install kubernetes using kubespray</p>

<p><a href="https://github.com/patsevanton/create-kubernetes-kubespray-gitlab-ci" rel="nofollow noreferrer">github repo</a></p>

<p>Change clusterip to nodeport command line without editor</p>

<pre><code>kubectl -n kube-system get service kubernetes-dashboard -o yaml &gt; kube-dash-svc.yaml
sed 's/ClusterIP/NodePort/' kube-dash-svc.yaml &gt; 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
</code></pre>

<p>After install and change clusterIP to nodeport i try install kubernetes again and get error:</p>

<p>err='The Service \"kubernetes-dashboard\" is invalid: \n* metadata.resourceVersion: Invalid value: \"\": must be specified for an update\n* spec.clusterIP: Invalid value: \"\": field is immutable\n* spec.ports[0].nodePort: Forbidden: may not be used when <code>type</code> is 'ClusterIP'\n'"}</p>

<p>How correct change clusterIP to nodeport of kubespray?</p>

<p>Thanks</p>

Anton Patsev
<p>ClusterIP can't simply change to nodeport just by replace ClusterIP with NodePort, since the ClusterIP is the default, there is maybe no 'ClusterIP' in the definitions at all.</p>

<p>You should delete everthing involve 'clusterIP/ClusterIP', then insert 'type: NodePort' in the proper place, something like:</p>

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