Skip to content

Commit

Permalink
Added node-public-ip annotation
Browse files Browse the repository at this point in the history
Signed-off-by: Roberto Bonafiglia <roberto.bonafiglia@suse.com>
  • Loading branch information
rbrtbnfgl committed May 29, 2024
1 parent bf59847 commit f2e1a37
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
5 changes: 3 additions & 2 deletions Documentation/kubernetes.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ If you want to deploy `flannel` securely in a shared namespace or want more fine
Other options include [Kyverno](https://kyverno.io/policies/pod-security/) and [OPA Gatekeeper](https://github.com/open-policy-agent/gatekeeper).
# Annotations

* `flannel.alpha.coreos.com/public-ip`, `flannel.alpha.coreos.com/public-ipv6`: Define the used public IP of the node. If configured when Flannel starts it'll be used as the `public-ip` and `public-ipv6` flag.
* `flannel.alpha.coreos.com/public-ip-overwrite`, `flannel.alpha.coreos.com/public-ipv6-overwrite`: Allows to overwrite the public IP of a node. Useful if the public IP can not determined from the node, e.G. because it is behind a NAT. It can be automatically set to a nodes `ExternalIP` using the [flannel-node-annotator](https://github.com/alvaroaleman/flannel-node-annotator).
Additional annotations can be configured on a specific node as parameters used when Flannel starts on that specific node
* `flannel.alpha.coreos.com/node-public-ip`, `flannel.alpha.coreos.com/node-public-ipv6`: Define the used IP of the node in case the node has multiple interface it selects the interface with the configured IP for the backend tunnel. If configured when Flannel starts it'll be used as the `public-ip` and `public-ipv6` flag.
* `flannel.alpha.coreos.com/public-ip-overwrite`, `flannel.alpha.coreos.com/public-ipv6-overwrite`: Allows to overwrite the public IP of a node that IP can be not configured on the node. Useful if the public IP can not determined from the node, e.G. because it is behind a NAT and the other nodes need to use it to create the tunnel. It can be automatically set to a nodes `ExternalIP` using the [flannel-node-annotator](https://github.com/alvaroaleman/flannel-node-annotator).
See also the "NAT" section in [troubleshooting](./troubleshooting.md) if UDP checksums seem corrupted.

## Older versions of Kubernetes
Expand Down
4 changes: 4 additions & 0 deletions pkg/subnet/kube/annotations.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ type annotations struct {
BackendType string
BackendPublicIP string
BackendPublicIPv6 string
BackendNodePublicIP string
BackendNodePublicIPv6 string
BackendPublicIPOverwrite string
BackendPublicIPv6Overwrite string
}
Expand Down Expand Up @@ -63,8 +65,10 @@ func newAnnotations(prefix string) (annotations, error) {
BackendV6Data: prefix + "backend-v6-data",
BackendType: prefix + "backend-type",
BackendPublicIP: prefix + "public-ip",
BackendNodePublicIP: prefix + "node-public-ip",
BackendPublicIPOverwrite: prefix + "public-ip-overwrite",
BackendPublicIPv6: prefix + "public-ipv6",
BackendNodePublicIPv6: prefix + "node-public-ipv6",
BackendPublicIPv6Overwrite: prefix + "public-ipv6-overwrite",
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/subnet/kube/kube.go
Original file line number Diff line number Diff line change
Expand Up @@ -653,8 +653,8 @@ func (ksm *kubeSubnetManager) GetStoredPublicIP(ctx context.Context) (string, st

if node != nil && node.Annotations != nil {
log.Infof("List of node(%s) annotations: %#+v", ksm.nodeName, node.Annotations)
publicIP := node.Annotations[ksm.annotations.BackendPublicIP]
publicIPv6 := node.Annotations[ksm.annotations.BackendPublicIPv6]
publicIP := node.Annotations[ksm.annotations.BackendNodePublicIP]
publicIPv6 := node.Annotations[ksm.annotations.BackendNodePublicIPv6]
return publicIP, publicIPv6
}

Expand Down

0 comments on commit f2e1a37

Please sign in to comment.