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

Automated cherry pick of #15414 upstream release 1.1 #18187

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 9 additions & 2 deletions cmd/kube-proxy/app/server.go
Expand Up @@ -102,6 +102,7 @@ const (
proxyModeUserspace = "userspace"
proxyModeIptables = "iptables"
experimentalProxyModeAnnotation = "net.experimental.kubernetes.io/proxy-mode"
betaProxyModeAnnotation = "net.beta.kubernetes.io/proxy-mode"
)

func checkKnownProxyMode(proxyMode string) bool {
Expand Down Expand Up @@ -359,9 +360,15 @@ func mayTryIptablesProxy(proxyMode string, client nodeGetter, hostname string) b
glog.Errorf("Not trying iptables proxy: got nil Node %q", hostname)
return false
}
proxyMode, found := node.Annotations[experimentalProxyModeAnnotation]
proxyMode, found := node.Annotations[betaProxyModeAnnotation]
if found {
glog.V(1).Infof("Found experimental annotation %q = %q", experimentalProxyModeAnnotation, proxyMode)
glog.V(1).Infof("Found beta annotation %q = %q", betaProxyModeAnnotation, proxyMode)
} else {
// We already published some information about this annotation with the "experimental" name, so we will respect it.
proxyMode, found = node.Annotations[experimentalProxyModeAnnotation]
if found {
glog.V(1).Infof("Found experimental annotation %q = %q", experimentalProxyModeAnnotation, proxyMode)
}
}
if proxyMode == proxyModeIptables {
glog.V(1).Infof("Annotation allows iptables proxy")
Expand Down
8 changes: 8 additions & 0 deletions cmd/kube-proxy/app/server_test.go
Expand Up @@ -44,11 +44,19 @@ func Test_mayTryIptablesProxy(t *testing.T) {
{"", "net.experimental.kubernetes.io/proxy-mode", "iptables", true},
{"", "net.experimental.kubernetes.io/proxy-mode", "other", false},
{"", "net.experimental.kubernetes.io/proxy-mode", "", false},
{"", "net.beta.kubernetes.io/proxy-mode", "userspace", false},
{"", "net.beta.kubernetes.io/proxy-mode", "iptables", true},
{"", "net.beta.kubernetes.io/proxy-mode", "other", false},
{"", "net.beta.kubernetes.io/proxy-mode", "", false},
{"", "proxy-mode", "iptables", false},
{"userspace", "net.experimental.kubernetes.io/proxy-mode", "userspace", false},
{"userspace", "net.experimental.kubernetes.io/proxy-mode", "iptables", false},
{"iptables", "net.experimental.kubernetes.io/proxy-mode", "userspace", true},
{"iptables", "net.experimental.kubernetes.io/proxy-mode", "iptables", true},
{"userspace", "net.beta.kubernetes.io/proxy-mode", "userspace", false},
{"userspace", "net.beta.kubernetes.io/proxy-mode", "iptables", false},
{"iptables", "net.beta.kubernetes.io/proxy-mode", "userspace", true},
{"iptables", "net.beta.kubernetes.io/proxy-mode", "iptables", true},
}
for i, c := range cases {
getter := &fakeNodeInterface{}
Expand Down
2 changes: 1 addition & 1 deletion docs/devel/api-conventions.md
Expand Up @@ -684,7 +684,7 @@ Therefore, resources supporting auto-generation of unique labels should have a `

Annotations have very different intended usage from labels. We expect them to be primarily generated and consumed by tooling and system extensions. I'm inclined to generalize annotations to permit them to directly store arbitrary json. Rigid names and name prefixes make sense, since they are analogous to API fields.

In fact, experimental API fields, including those used to represent fields of newer alpha/beta API versions in the older stable storage version, may be represented as annotations with the form `something.experimental.kubernetes.io/name`. For example `net.experimental.kubernetes.io/policy` might represent an experimental network policy field.
In fact, in-development API fields, including those used to represent fields of newer alpha/beta API versions in the older stable storage version, may be represented as annotations with the form `something.alpha.kubernetes.io/name` or `something.beta.kubernetes.io/name` (depending on our confidence in it). For example `net.alpha.kubernetes.io/policy` might represent an experimental network policy field.

Other advice regarding use of labels, annotations, and other generic map keys by Kubernetes components and tools:
- Key names should be all lowercase, with words separated by dashes, such as `desired-replicas`
Expand Down