mirror of https://github.com/kubernetes/kops.git
allow overriding subnet tags in the NetworkSpec
This commit is contained in:
parent
af7377d530
commit
f0a7fa785c
|
@ -191,4 +191,6 @@ type CiliumNetworkingSpec struct {
|
|||
}
|
||||
|
||||
// LyftIpVlanNetworkingSpec declares that we want to use the cni-ipvlan-vpc-k8s CNI networking
|
||||
type LyftVPCNetworkingSpec struct{}
|
||||
type LyftVPCNetworkingSpec struct {
|
||||
SubnetTags map[string]string `json:"subnetTags,omitempty"`
|
||||
}
|
||||
|
|
|
@ -188,4 +188,6 @@ type CiliumNetworkingSpec struct {
|
|||
}
|
||||
|
||||
// LyftIpVlanNetworkingSpec declares that we want to use the cni-ipvlan-vpc-k8s CNI networking
|
||||
type LyftVPCNetworkingSpec struct{}
|
||||
type LyftVPCNetworkingSpec struct {
|
||||
SubnetTags map[string]string `json:"subnetTags,omitempty"`
|
||||
}
|
||||
|
|
|
@ -2792,6 +2792,7 @@ func Convert_kops_LoadBalancerAccessSpec_To_v1alpha1_LoadBalancerAccessSpec(in *
|
|||
}
|
||||
|
||||
func autoConvert_v1alpha1_LyftVPCNetworkingSpec_To_kops_LyftVPCNetworkingSpec(in *LyftVPCNetworkingSpec, out *kops.LyftVPCNetworkingSpec, s conversion.Scope) error {
|
||||
out.SubnetTags = in.SubnetTags
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -2801,6 +2802,7 @@ func Convert_v1alpha1_LyftVPCNetworkingSpec_To_kops_LyftVPCNetworkingSpec(in *Ly
|
|||
}
|
||||
|
||||
func autoConvert_kops_LyftVPCNetworkingSpec_To_v1alpha1_LyftVPCNetworkingSpec(in *kops.LyftVPCNetworkingSpec, out *LyftVPCNetworkingSpec, s conversion.Scope) error {
|
||||
out.SubnetTags = in.SubnetTags
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -2970,6 +2970,13 @@ func (in *LoadBalancerAccessSpec) DeepCopy() *LoadBalancerAccessSpec {
|
|||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *LyftVPCNetworkingSpec) DeepCopyInto(out *LyftVPCNetworkingSpec) {
|
||||
*out = *in
|
||||
if in.SubnetTags != nil {
|
||||
in, out := &in.SubnetTags, &out.SubnetTags
|
||||
*out = make(map[string]string, len(*in))
|
||||
for key, val := range *in {
|
||||
(*out)[key] = val
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -3109,7 +3116,7 @@ func (in *NetworkingSpec) DeepCopyInto(out *NetworkingSpec) {
|
|||
*out = nil
|
||||
} else {
|
||||
*out = new(LyftVPCNetworkingSpec)
|
||||
**out = **in
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
}
|
||||
return
|
||||
|
|
|
@ -189,4 +189,6 @@ type CiliumNetworkingSpec struct {
|
|||
}
|
||||
|
||||
// LyftIpVlanNetworkingSpec declares that we want to use the cni-ipvlan-vpc-k8s CNI networking
|
||||
type LyftVPCNetworkingSpec struct{}
|
||||
type LyftVPCNetworkingSpec struct {
|
||||
SubnetTags map[string]string `json:"subnetTags,omitempty"`
|
||||
}
|
||||
|
|
|
@ -3056,6 +3056,7 @@ func Convert_kops_LoadBalancerAccessSpec_To_v1alpha2_LoadBalancerAccessSpec(in *
|
|||
}
|
||||
|
||||
func autoConvert_v1alpha2_LyftVPCNetworkingSpec_To_kops_LyftVPCNetworkingSpec(in *LyftVPCNetworkingSpec, out *kops.LyftVPCNetworkingSpec, s conversion.Scope) error {
|
||||
out.SubnetTags = in.SubnetTags
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -3065,6 +3066,7 @@ func Convert_v1alpha2_LyftVPCNetworkingSpec_To_kops_LyftVPCNetworkingSpec(in *Ly
|
|||
}
|
||||
|
||||
func autoConvert_kops_LyftVPCNetworkingSpec_To_v1alpha2_LyftVPCNetworkingSpec(in *kops.LyftVPCNetworkingSpec, out *LyftVPCNetworkingSpec, s conversion.Scope) error {
|
||||
out.SubnetTags = in.SubnetTags
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -3051,6 +3051,13 @@ func (in *LoadBalancerAccessSpec) DeepCopy() *LoadBalancerAccessSpec {
|
|||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *LyftVPCNetworkingSpec) DeepCopyInto(out *LyftVPCNetworkingSpec) {
|
||||
*out = *in
|
||||
if in.SubnetTags != nil {
|
||||
in, out := &in.SubnetTags, &out.SubnetTags
|
||||
*out = make(map[string]string, len(*in))
|
||||
for key, val := range *in {
|
||||
(*out)[key] = val
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -3190,7 +3197,7 @@ func (in *NetworkingSpec) DeepCopyInto(out *NetworkingSpec) {
|
|||
*out = nil
|
||||
} else {
|
||||
*out = new(LyftVPCNetworkingSpec)
|
||||
**out = **in
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
}
|
||||
return
|
||||
|
|
|
@ -3255,6 +3255,13 @@ func (in *LoadBalancerAccessSpec) DeepCopy() *LoadBalancerAccessSpec {
|
|||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *LyftVPCNetworkingSpec) DeepCopyInto(out *LyftVPCNetworkingSpec) {
|
||||
*out = *in
|
||||
if in.SubnetTags != nil {
|
||||
in, out := &in.SubnetTags, &out.SubnetTags
|
||||
*out = make(map[string]string, len(*in))
|
||||
for key, val := range *in {
|
||||
(*out)[key] = val
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -3394,7 +3401,7 @@ func (in *NetworkingSpec) DeepCopyInto(out *NetworkingSpec) {
|
|||
*out = nil
|
||||
} else {
|
||||
*out = new(LyftVPCNetworkingSpec)
|
||||
**out = **in
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
}
|
||||
return
|
||||
|
|
|
@ -10,9 +10,7 @@
|
|||
"ipam": {
|
||||
"type": "cni-ipvlan-vpc-k8s-ipam",
|
||||
"interfaceIndex": 1,
|
||||
"subnetTags": {
|
||||
"Type": "pod"
|
||||
},
|
||||
"subnetTags": {{ SubnetTags }},
|
||||
"routeToVpcPeers": true,
|
||||
"secGroupIds": {{ NodeSecurityGroups }}
|
||||
}
|
||||
|
|
|
@ -253,6 +253,22 @@ func (c *NodeUpCommand) Run(out io.Writer) error {
|
|||
}
|
||||
|
||||
if c.cluster.Spec.Networking.LyftVPC != nil {
|
||||
|
||||
loader.TemplateFunctions["SubnetTags"] = func() (string, error) {
|
||||
tags := map[string]string{
|
||||
"Type": "pod",
|
||||
}
|
||||
if len(c.cluster.Spec.Networking.LyftVPC.SubnetTags) > 0 {
|
||||
tags = c.cluster.Spec.Networking.LyftVPC.SubnetTags
|
||||
}
|
||||
|
||||
bytes, err := json.Marshal(tags)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return string(bytes), nil
|
||||
}
|
||||
|
||||
loader.TemplateFunctions["NodeSecurityGroups"] = func() (string, error) {
|
||||
// use the same security groups as the node
|
||||
ids, err := evaluateSecurityGroups(c.cluster.Spec.NetworkID)
|
||||
|
|
Loading…
Reference in New Issue