Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamically assign DNS IP using cni-env #210

Merged
merged 6 commits into from
Jul 27, 2023
Merged

Conversation

sachinkumarsingh092
Copy link
Contributor

Summary

Earlier we used to assign DNS IP statically. But now we use the CIDR in cni-env to assign a valid IP from that range removing hard-coded IP.
We add new utilities in the utils.sh to calculate and test a valid IP from the cidr. Not using external utils like ipcalc, as they may not be present in every system.

Copy link
Contributor

@neoaggelos neoaggelos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it not better to simply deploy the service without a fixed IP address, and then query KubeAPIserver with the address?

I cannot see the reason to add all this logic just to pick a random IP of a valid range, when Kubernetes will do that for us either way.

@sachinkumarsingh092
Copy link
Contributor Author

We now assign DNSIP after deploying the service and assign arguments in kubelet based on the Cluster IP assigned to the DNS service. We also remove DNSIPARGS and assign IP to the DNS service dynamically only.

Copy link
Contributor

@neoaggelos neoaggelos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works much better. However, setting the DNS IP address as a second argument must still be supported.

You can support both by setting clusterIP if $2 is provided, otherwise leave it as an empty value.

@sachinkumarsingh092
Copy link
Contributor Author

But the DNSIP env variable cannot be an empty value inside the manifest. Otherwise we will get errors like:

The Service "kube-dns" is invalid: spec.clusterIPs[0]: Invalid value: "$DNSIP": must be a valid IP address, (e.g. 10.9.8.7 or 2001:db8::ffff)

@neoaggelos
Copy link
Contributor

Yes, this is because $DNSIP is not replaced in the manifest, and is rejected because of this. Try the following:

# works
apiVersion: v1
kind: Service
metadata:
  name: svc-1
spec:
  clusterIP: 
  ports:
  - port: 80
    protocol: TCP
    targetPort: 80
---
# does not work
apiVersion: v1
kind: Service
metadata:
  name: svc-2
spec:
  clusterIP: "$DNSIP"
  ports:
  - port: 80
    protocol: TCP
    targetPort: 80

addons/dns/coredns.yaml Outdated Show resolved Hide resolved
@neoaggelos neoaggelos self-requested a review July 27, 2023 20:01
@neoaggelos neoaggelos merged commit e16471c into main Jul 27, 2023
4 checks passed
@neoaggelos neoaggelos deleted the MK-1286/dns-cidr-cni-env branch July 27, 2023 20:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants