Closed JasperDiShu closed 3 months ago
ditto ..
perl -i -ne 'if (/^ *clusterIP:/) { <>; <>; next; } print' filename.yaml
got rid of it for me.
I'll take a shot at this
EDIT: actually there was a feature and PR made for this with some helpful discussion https://github.com/itaysk/kubectl-neat/issues/44#issuecomment-698593139
duplicate of https://github.com/itaysk/kubectl-neat/issues/44
Description: When I use the kubectl-neat 2.0.3 to do the clean of yaml file, I found that after neaten the yaml of a svc, the yaml still contains the part of clusterIP and clusterIPs. In the scenario that I generated the yaml file in a svcCIDR range is 172.21.0.0/16 k8s environment, but apply these svc yaml files in a new environment that svcCIDR is 192.168.0.0/16, it will occur the error that 'failed to allocated ip:172.21.132.103 with error:provided IP is not in the valid range. The range of valid IPs is 192.168.0.0/16'.
What I expected to happen: I think these part 'clusterIP and clusterIPs' in the yaml is not the mandatory part, perhaps it could be remove by the kubectl-neat function. Thanks for your time to look at this issue.
Some addition output I can provide: Original svc yaml content:
apiVersion: v1 kind: Service metadata: annotations: meta.helm.sh/release-name: minimum meta.helm.sh/release-namespace: default creationTimestamp: "2022-09-07T02:19:41Z" labels: app: im app.kubernetes.io/managed-by: Helm grp: xxxx managedFields:
Neat svc yaml content:
apiVersion: v1 kind: Service metadata: annotations: meta.helm.sh/release-name: minimum meta.helm.sh/release-namespace: default labels: app: im app.kubernetes.io/managed-by: Helm grp: xxx name: im namespace: default spec: clusterIP: 172.21.132.103 clusterIPs:
The error info when I applied the neat yaml in a new env which svcCIDR changed:
The Service "xxx" is invalid: spec.clusterIPs: Invalid value: []string{"172.21.132.103"}: failed to allocated ip:172.21.132.103 with error:provided IP is not in the valid range. The range of valid IPs is 192.168.0.0/16
Environment:
OS: CentOS Linux release 7.9.2009 (Core)
Kernel: Linux iZuf638qwylkt54jqjznyuZ 3.10.0-1160.66.1.el7.x86_64 #1 SMP Wed May 18 16:02:34 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux