allow overriding subnet tags in the NetworkSpec

This commit is contained in:
Chris Phillips 2018-06-22 10:13:30 -07:00
parent af7377d530
commit f0a7fa785c
10 changed files with 54 additions and 9 deletions

View File

@ -191,4 +191,6 @@ type CiliumNetworkingSpec struct {
} }
// LyftIpVlanNetworkingSpec declares that we want to use the cni-ipvlan-vpc-k8s CNI networking // 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"`
}

View File

@ -188,4 +188,6 @@ type CiliumNetworkingSpec struct {
} }
// LyftIpVlanNetworkingSpec declares that we want to use the cni-ipvlan-vpc-k8s CNI networking // 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"`
}

View File

@ -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 { func autoConvert_v1alpha1_LyftVPCNetworkingSpec_To_kops_LyftVPCNetworkingSpec(in *LyftVPCNetworkingSpec, out *kops.LyftVPCNetworkingSpec, s conversion.Scope) error {
out.SubnetTags = in.SubnetTags
return nil 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 { func autoConvert_kops_LyftVPCNetworkingSpec_To_v1alpha1_LyftVPCNetworkingSpec(in *kops.LyftVPCNetworkingSpec, out *LyftVPCNetworkingSpec, s conversion.Scope) error {
out.SubnetTags = in.SubnetTags
return nil return nil
} }

View File

@ -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. // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *LyftVPCNetworkingSpec) DeepCopyInto(out *LyftVPCNetworkingSpec) { func (in *LyftVPCNetworkingSpec) DeepCopyInto(out *LyftVPCNetworkingSpec) {
*out = *in *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 return
} }
@ -3109,7 +3116,7 @@ func (in *NetworkingSpec) DeepCopyInto(out *NetworkingSpec) {
*out = nil *out = nil
} else { } else {
*out = new(LyftVPCNetworkingSpec) *out = new(LyftVPCNetworkingSpec)
**out = **in (*in).DeepCopyInto(*out)
} }
} }
return return

View File

@ -189,4 +189,6 @@ type CiliumNetworkingSpec struct {
} }
// LyftIpVlanNetworkingSpec declares that we want to use the cni-ipvlan-vpc-k8s CNI networking // 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"`
}

View File

@ -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 { func autoConvert_v1alpha2_LyftVPCNetworkingSpec_To_kops_LyftVPCNetworkingSpec(in *LyftVPCNetworkingSpec, out *kops.LyftVPCNetworkingSpec, s conversion.Scope) error {
out.SubnetTags = in.SubnetTags
return nil 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 { func autoConvert_kops_LyftVPCNetworkingSpec_To_v1alpha2_LyftVPCNetworkingSpec(in *kops.LyftVPCNetworkingSpec, out *LyftVPCNetworkingSpec, s conversion.Scope) error {
out.SubnetTags = in.SubnetTags
return nil return nil
} }

View File

@ -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. // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *LyftVPCNetworkingSpec) DeepCopyInto(out *LyftVPCNetworkingSpec) { func (in *LyftVPCNetworkingSpec) DeepCopyInto(out *LyftVPCNetworkingSpec) {
*out = *in *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 return
} }
@ -3190,7 +3197,7 @@ func (in *NetworkingSpec) DeepCopyInto(out *NetworkingSpec) {
*out = nil *out = nil
} else { } else {
*out = new(LyftVPCNetworkingSpec) *out = new(LyftVPCNetworkingSpec)
**out = **in (*in).DeepCopyInto(*out)
} }
} }
return return

View File

@ -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. // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *LyftVPCNetworkingSpec) DeepCopyInto(out *LyftVPCNetworkingSpec) { func (in *LyftVPCNetworkingSpec) DeepCopyInto(out *LyftVPCNetworkingSpec) {
*out = *in *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 return
} }
@ -3394,7 +3401,7 @@ func (in *NetworkingSpec) DeepCopyInto(out *NetworkingSpec) {
*out = nil *out = nil
} else { } else {
*out = new(LyftVPCNetworkingSpec) *out = new(LyftVPCNetworkingSpec)
**out = **in (*in).DeepCopyInto(*out)
} }
} }
return return

View File

@ -10,9 +10,7 @@
"ipam": { "ipam": {
"type": "cni-ipvlan-vpc-k8s-ipam", "type": "cni-ipvlan-vpc-k8s-ipam",
"interfaceIndex": 1, "interfaceIndex": 1,
"subnetTags": { "subnetTags": {{ SubnetTags }},
"Type": "pod"
},
"routeToVpcPeers": true, "routeToVpcPeers": true,
"secGroupIds": {{ NodeSecurityGroups }} "secGroupIds": {{ NodeSecurityGroups }}
} }

View File

@ -253,6 +253,22 @@ func (c *NodeUpCommand) Run(out io.Writer) error {
} }
if c.cluster.Spec.Networking.LyftVPC != nil { 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) { loader.TemplateFunctions["NodeSecurityGroups"] = func() (string, error) {
// use the same security groups as the node // use the same security groups as the node
ids, err := evaluateSecurityGroups(c.cluster.Spec.NetworkID) ids, err := evaluateSecurityGroups(c.cluster.Spec.NetworkID)