mirror of https://github.com/k3s-io/k3s
commit
6dc3dcf36a
|
@ -100,6 +100,7 @@ const (
|
||||||
proxyModeUserspace = "userspace"
|
proxyModeUserspace = "userspace"
|
||||||
proxyModeIptables = "iptables"
|
proxyModeIptables = "iptables"
|
||||||
experimentalProxyModeAnnotation = "net.experimental.kubernetes.io/proxy-mode"
|
experimentalProxyModeAnnotation = "net.experimental.kubernetes.io/proxy-mode"
|
||||||
|
betaProxyModeAnnotation = "net.beta.kubernetes.io/proxy-mode"
|
||||||
)
|
)
|
||||||
|
|
||||||
func checkKnownProxyMode(proxyMode string) bool {
|
func checkKnownProxyMode(proxyMode string) bool {
|
||||||
|
@ -330,9 +331,15 @@ func mayTryIptablesProxy(proxyMode string, client nodeGetter, hostname string) b
|
||||||
glog.Errorf("Not trying iptables proxy: got nil Node %q", hostname)
|
glog.Errorf("Not trying iptables proxy: got nil Node %q", hostname)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
proxyMode, found := node.Annotations[experimentalProxyModeAnnotation]
|
proxyMode, found := node.Annotations[betaProxyModeAnnotation]
|
||||||
if found {
|
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 {
|
if proxyMode == proxyModeIptables {
|
||||||
glog.V(1).Infof("Annotation allows iptables proxy")
|
glog.V(1).Infof("Annotation allows iptables proxy")
|
||||||
|
|
|
@ -45,11 +45,19 @@ func Test_mayTryIptablesProxy(t *testing.T) {
|
||||||
{"", "net.experimental.kubernetes.io/proxy-mode", "iptables", true},
|
{"", "net.experimental.kubernetes.io/proxy-mode", "iptables", true},
|
||||||
{"", "net.experimental.kubernetes.io/proxy-mode", "other", false},
|
{"", "net.experimental.kubernetes.io/proxy-mode", "other", false},
|
||||||
{"", "net.experimental.kubernetes.io/proxy-mode", "", 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},
|
{"", "proxy-mode", "iptables", false},
|
||||||
{"userspace", "net.experimental.kubernetes.io/proxy-mode", "userspace", false},
|
{"userspace", "net.experimental.kubernetes.io/proxy-mode", "userspace", false},
|
||||||
{"userspace", "net.experimental.kubernetes.io/proxy-mode", "iptables", 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", "userspace", true},
|
||||||
{"iptables", "net.experimental.kubernetes.io/proxy-mode", "iptables", 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 {
|
for i, c := range cases {
|
||||||
getter := &fakeNodeInterface{}
|
getter := &fakeNodeInterface{}
|
||||||
|
|
|
@ -746,7 +746,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.
|
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:
|
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`
|
- Key names should be all lowercase, with words separated by dashes, such as `desired-replicas`
|
||||||
|
|
|
@ -2858,7 +2858,7 @@ func validateBandwidthIsReasonable(rsrc *resource.Quantity) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func extractBandwidthResources(pod *api.Pod) (ingress, egress *resource.Quantity, err error) {
|
func extractBandwidthResources(pod *api.Pod) (ingress, egress *resource.Quantity, err error) {
|
||||||
str, found := pod.Annotations["kubernetes.io/ingress-bandwidth"]
|
str, found := pod.Annotations["net.alpha.kubernetes.io/ingress-bandwidth"]
|
||||||
if found {
|
if found {
|
||||||
if ingress, err = resource.ParseQuantity(str); err != nil {
|
if ingress, err = resource.ParseQuantity(str); err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
|
@ -2867,7 +2867,7 @@ func extractBandwidthResources(pod *api.Pod) (ingress, egress *resource.Quantity
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
str, found = pod.Annotations["kubernetes.io/egress-bandwidth"]
|
str, found = pod.Annotations["net.alpha.kubernetes.io/egress-bandwidth"]
|
||||||
if found {
|
if found {
|
||||||
if egress, err = resource.ParseQuantity(str); err != nil {
|
if egress, err = resource.ParseQuantity(str); err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
|
|
|
@ -3529,7 +3529,7 @@ func TestCleanupBandwidthLimits(t *testing.T) {
|
||||||
ObjectMeta: api.ObjectMeta{
|
ObjectMeta: api.ObjectMeta{
|
||||||
Name: "foo",
|
Name: "foo",
|
||||||
Annotations: map[string]string{
|
Annotations: map[string]string{
|
||||||
"kubernetes.io/ingress-bandwidth": "10M",
|
"net.alpha.kubernetes.io/ingress-bandwidth": "10M",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -3554,7 +3554,7 @@ func TestCleanupBandwidthLimits(t *testing.T) {
|
||||||
ObjectMeta: api.ObjectMeta{
|
ObjectMeta: api.ObjectMeta{
|
||||||
Name: "foo",
|
Name: "foo",
|
||||||
Annotations: map[string]string{
|
Annotations: map[string]string{
|
||||||
"kubernetes.io/ingress-bandwidth": "10M",
|
"net.alpha.kubernetes.io/ingress-bandwidth": "10M",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -3580,7 +3580,7 @@ func TestCleanupBandwidthLimits(t *testing.T) {
|
||||||
ObjectMeta: api.ObjectMeta{
|
ObjectMeta: api.ObjectMeta{
|
||||||
Name: "foo",
|
Name: "foo",
|
||||||
Annotations: map[string]string{
|
Annotations: map[string]string{
|
||||||
"kubernetes.io/ingress-bandwidth": "10M",
|
"net.alpha.kubernetes.io/ingress-bandwidth": "10M",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -3605,7 +3605,7 @@ func TestCleanupBandwidthLimits(t *testing.T) {
|
||||||
ObjectMeta: api.ObjectMeta{
|
ObjectMeta: api.ObjectMeta{
|
||||||
Name: "foo",
|
Name: "foo",
|
||||||
Annotations: map[string]string{
|
Annotations: map[string]string{
|
||||||
"kubernetes.io/ingress-bandwidth": "10M",
|
"net.alpha.kubernetes.io/ingress-bandwidth": "10M",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -3693,7 +3693,7 @@ func TestExtractBandwidthResources(t *testing.T) {
|
||||||
pod: &api.Pod{
|
pod: &api.Pod{
|
||||||
ObjectMeta: api.ObjectMeta{
|
ObjectMeta: api.ObjectMeta{
|
||||||
Annotations: map[string]string{
|
Annotations: map[string]string{
|
||||||
"kubernetes.io/ingress-bandwidth": "10M",
|
"net.alpha.kubernetes.io/ingress-bandwidth": "10M",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -3703,7 +3703,7 @@ func TestExtractBandwidthResources(t *testing.T) {
|
||||||
pod: &api.Pod{
|
pod: &api.Pod{
|
||||||
ObjectMeta: api.ObjectMeta{
|
ObjectMeta: api.ObjectMeta{
|
||||||
Annotations: map[string]string{
|
Annotations: map[string]string{
|
||||||
"kubernetes.io/egress-bandwidth": "10M",
|
"net.alpha.kubernetes.io/egress-bandwidth": "10M",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -3713,8 +3713,8 @@ func TestExtractBandwidthResources(t *testing.T) {
|
||||||
pod: &api.Pod{
|
pod: &api.Pod{
|
||||||
ObjectMeta: api.ObjectMeta{
|
ObjectMeta: api.ObjectMeta{
|
||||||
Annotations: map[string]string{
|
Annotations: map[string]string{
|
||||||
"kubernetes.io/ingress-bandwidth": "4M",
|
"net.alpha.kubernetes.io/ingress-bandwidth": "4M",
|
||||||
"kubernetes.io/egress-bandwidth": "20M",
|
"net.alpha.kubernetes.io/egress-bandwidth": "20M",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -3725,7 +3725,7 @@ func TestExtractBandwidthResources(t *testing.T) {
|
||||||
pod: &api.Pod{
|
pod: &api.Pod{
|
||||||
ObjectMeta: api.ObjectMeta{
|
ObjectMeta: api.ObjectMeta{
|
||||||
Annotations: map[string]string{
|
Annotations: map[string]string{
|
||||||
"kubernetes.io/ingress-bandwidth": "foo",
|
"net.alpha.kubernetes.io/ingress-bandwidth": "foo",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue