drop v1alpha3

This commit is contained in:
Benjamin Elder
2020-04-29 01:42:26 -07:00
parent cb7fbe6697
commit 3abbcbbb99
11 changed files with 0 additions and 782 deletions

View File

@@ -45,7 +45,6 @@ cd "${FAKE_REPOPATH}"
# run the generators
bin/deepcopy-gen -i ./pkg/internal/apis/config/ -O zz_generated.deepcopy --go-header-file hack/tools/boilerplate.go.txt
bin/deepcopy-gen -i ./pkg/apis/config/v1alpha3 -O zz_generated.deepcopy --go-header-file hack/tools/boilerplate.go.txt
bin/deepcopy-gen -i ./pkg/apis/config/v1alpha4 -O zz_generated.deepcopy --go-header-file hack/tools/boilerplate.go.txt

View File

@@ -1,77 +0,0 @@
/*
Copyright 2019 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package v1alpha3
import (
"sigs.k8s.io/kind/pkg/apis/config/defaults"
)
// SetDefaultsCluster sets uninitialized fields to their default value.
func SetDefaultsCluster(obj *Cluster) {
// default to a one node cluster
if len(obj.Nodes) == 0 {
obj.Nodes = []Node{
{
Image: defaults.Image,
Role: ControlPlaneRole,
},
}
}
// default the nodes
for i := range obj.Nodes {
a := &obj.Nodes[i]
SetDefaultsNode(a)
}
if obj.Networking.IPFamily == "" {
obj.Networking.IPFamily = "ipv4"
}
// default to listening on 127.0.0.1:randomPort on ipv4
// and [::1]:randomPort on ipv6
if obj.Networking.APIServerAddress == "" {
obj.Networking.APIServerAddress = "127.0.0.1"
if obj.Networking.IPFamily == "ipv6" {
obj.Networking.APIServerAddress = "::1"
}
}
// default the pod CIDR
if obj.Networking.PodSubnet == "" {
obj.Networking.PodSubnet = "10.244.0.0/16"
if obj.Networking.IPFamily == "ipv6" {
obj.Networking.PodSubnet = "fd00:10:244::/64"
}
}
// default the service CIDR using the kubeadm default
// https://github.com/kubernetes/kubernetes/blob/746404f82a28e55e0b76ffa7e40306fb88eb3317/cmd/kubeadm/app/apis/kubeadm/v1beta2/defaults.go#L32
// Note: kubeadm is doing it already but this simplifies kind's logic
if obj.Networking.ServiceSubnet == "" {
obj.Networking.ServiceSubnet = "10.96.0.0/12"
if obj.Networking.IPFamily == "ipv6" {
obj.Networking.ServiceSubnet = "fd00:10:96::/112"
}
}
}
// SetDefaultsNode sets uninitialized fields to their default value.
func SetDefaultsNode(obj *Node) {
if obj.Image == "" {
obj.Image = defaults.Image
}
if obj.Role == "" {
obj.Role = ControlPlaneRole
}
}

View File

@@ -1,22 +0,0 @@
/*
Copyright 2019 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Package v1alpha3 implements the v1alpha3 apiVersion of kind's cluster
// configuration
//
// +k8s:deepcopy-gen=package
// +k8s:defaulter-gen=TypeMeta
package v1alpha3

View File

@@ -1,273 +0,0 @@
/*
Copyright 2019 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package v1alpha3
// Cluster contains kind cluster configuration
type Cluster struct {
TypeMeta `yaml:",inline"`
// Nodes contains the list of nodes defined in the `kind` Cluster
// If unset this will default to a single control-plane node
// Note that if more than one control plane is specified, an external
// control plane load balancer will be provisioned implicitly
Nodes []Node `yaml:"nodes,omitempty"`
/* Advanced fields */
// Networking contains cluster wide network settings
Networking Networking `yaml:"networking,omitempty"`
// KubeadmConfigPatches are applied to the generated kubeadm config as
// merge patches. The `kind` field must match the target object, and
// if `apiVersion` is specified it will only be applied to matching objects.
//
// This should be an inline yaml blob-string
//
// https://tools.ietf.org/html/rfc7386
KubeadmConfigPatches []string `yaml:"kubeadmConfigPatches,omitempty"`
// KubeadmConfigPatchesJSON6902 are applied to the generated kubeadm config
// as JSON 6902 patches. The `kind` field must match the target object, and
// if group or version are specified it will only be objects matching the
// apiVersion: group+"/"+version
//
// Name and Namespace are now ignored, but the fields continue to exist for
// backwards compatibility of parsing the config. The name of the generated
// config was/is always fixed as is the namespace so these fields have
// always been a no-op.
//
// https://tools.ietf.org/html/rfc6902
KubeadmConfigPatchesJSON6902 []PatchJSON6902 `yaml:"kubeadmConfigPatchesJson6902,omitempty"`
}
// TypeMeta partially copies apimachinery/pkg/apis/meta/v1.TypeMeta
// No need for a direct dependence; the fields are stable.
type TypeMeta struct {
Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
APIVersion string `json:"apiVersion,omitempty" yaml:"apiVersion,omitempty"`
}
// Node contains settings for a node in the `kind` Cluster.
// A node in kind config represent a container that will be provisioned with all the components
// required for the assigned role in the Kubernetes cluster
type Node struct {
// Role defines the role of the node in the in the Kubernetes cluster
// created by kind
//
// Defaults to "control-plane"
Role NodeRole `yaml:"role,omitempty"`
// Image is the node image to use when creating this node
// If unset a default image will be used, see defaults.Image
Image string `yaml:"image,omitempty"`
/* Advanced fields */
// TODO: cri-like types should be inline instead
// ExtraMounts describes additional mount points for the node container
// These may be used to bind a hostPath
ExtraMounts []Mount `yaml:"extraMounts,omitempty"`
// ExtraPortMappings describes additional port mappings for the node container
// binded to a host Port
ExtraPortMappings []PortMapping `yaml:"extraPortMappings,omitempty"`
}
// NodeRole defines possible role for nodes in a Kubernetes cluster managed by `kind`
type NodeRole string
const (
// ControlPlaneRole identifies a node that hosts a Kubernetes control-plane.
// NOTE: in single node clusters, control-plane nodes act also as a worker
// nodes, in which case the taint will be removed. see:
// https://kubernetes.io/docs/setup/independent/create-cluster-kubeadm/#control-plane-node-isolation
ControlPlaneRole NodeRole = "control-plane"
// WorkerRole identifies a node that hosts a Kubernetes worker
WorkerRole NodeRole = "worker"
)
// Networking contains cluster wide network settings
type Networking struct {
// IPFamily is the network cluster model, currently it can be ipv4 or ipv6
IPFamily ClusterIPFamily `yaml:"ipFamily,omitempty"`
// APIServerPort is the listen port on the host for the Kubernetes API Server
// Defaults to a random port on the host obtained by kind
//
// NOTE: if you set the special value of `-1` then the node backend
// (docker, podman...) will be left to pick the port instead.
// This is potentially useful for remote hosts, BUT it means when the container
// is restarted it will be randomized. Leave this unset to allow kind to pick it.
APIServerPort int32 `yaml:"apiServerPort,omitempty"`
// APIServerAddress is the listen address on the host for the Kubernetes
// API Server. This should be an IP address.
//
// Defaults to 127.0.0.1
APIServerAddress string `yaml:"apiServerAddress,omitempty"`
// PodSubnet is the CIDR used for pod IPs
// kind will select a default if unspecified
PodSubnet string `yaml:"podSubnet,omitempty"`
// ServiceSubnet is the CIDR used for services VIPs
// kind will select a default if unspecified for IPv6
ServiceSubnet string `yaml:"serviceSubnet,omitempty"`
// If DisableDefaultCNI is true, kind will not install the default CNI setup.
// Instead the user should install their own CNI after creating the cluster.
DisableDefaultCNI bool `yaml:"disableDefaultCNI,omitempty"`
}
// ClusterIPFamily defines cluster network IP family
type ClusterIPFamily string
const (
// IPv4Family sets ClusterIPFamily to ipv4
IPv4Family ClusterIPFamily = "ipv4"
// IPv6Family sets ClusterIPFamily to ipv6
IPv6Family ClusterIPFamily = "ipv6"
)
// PatchJSON6902 represents an inline kustomize json 6902 patch
// https://tools.ietf.org/html/rfc6902
type PatchJSON6902 struct {
// these fields specify the patch target resource
Group string `yaml:"group"`
Version string `yaml:"version"`
Kind string `yaml:"kind"`
// WARNING: Name & Namespace are actually ignored!
// See the docs for the Cluster type
Name string `yaml:"name,omitempty"`
Namespace string `yaml:"namespace,omitempty"`
// Patch should contain the contents of the json patch as a string
Patch string `yaml:"patch"`
}
/*
These types are from
https://github.com/kubernetes/kubernetes/blob/063e7ff358fdc8b0916e6f39beedc0d025734cb1/pkg/kubelet/apis/cri/runtime/v1alpha2/api.pb.go#L183
*/
// Mount specifies a host volume to mount into a container.
// This is a close copy of the upstream cri Mount type
// see: k8s.io/kubernetes/pkg/kubelet/apis/cri/runtime/v1alpha2
// It additionally serializes the "propagation" field with the string enum
// names on disk as opposed to the int32 values, and the serlialzed field names
// have been made closer to core/v1 VolumeMount field names
// In yaml this looks like:
// containerPath: /foo
// hostPath: /bar
// readOnly: true
// selinuxRelabel: false
// propagation: None
// Propagation may be one of: None, HostToContainer, Bidirectional
type Mount struct {
// Path of the mount within the container.
ContainerPath string `yaml:"containerPath,omitempty"`
// Path of the mount on the host. If the hostPath doesn't exist, then runtimes
// should report error. If the hostpath is a symbolic link, runtimes should
// follow the symlink and mount the real destination to container.
HostPath string `yaml:"hostPath,omitempty"`
// If set, the mount is read-only.
Readonly bool `yaml:"readOnly,omitempty"`
// If set, the mount needs SELinux relabeling.
SelinuxRelabel bool `yaml:"selinuxRelabel,omitempty"`
// Requested propagation mode.
Propagation MountPropagation `yaml:"propagation,omitempty"`
}
// PortMapping specifies a host port mapped into a container port.
// In yaml this looks like:
// containerPort: 80
// hostPort: 8000
// listenAddress: 127.0.0.1
// protocol: TCP
type PortMapping struct {
// Port within the container.
ContainerPort int32 `yaml:"containerPort,omitempty"`
// Port on the host.
//
// If unset, a random port will be selected.
//
// NOTE: if you set the special value of `-1` then the node backend
// (docker, podman...) will be left to pick the port instead.
// This is potentially useful for remote hosts, BUT it means when the container
// is restarted it will be randomized. Leave this unset to allow kind to pick it.
HostPort int32 `yaml:"hostPort,omitempty"`
// TODO: add protocol (tcp/udp) and port-ranges
ListenAddress string `yaml:"listenAddress,omitempty"`
// Protocol (TCP/UDP)
Protocol PortMappingProtocol `yaml:"protocol,omitempty"`
}
// MountPropagation represents an "enum" for mount propagation options,
// see also Mount.
type MountPropagation int32
const (
// MountPropagationNone specifies that no mount propagation
// ("private" in Linux terminology).
MountPropagationNone MountPropagation = 0
// MountPropagationHostToContainer specifies that mounts get propagated
// from the host to the container ("rslave" in Linux).
MountPropagationHostToContainer MountPropagation = 1
// MountPropagationBidirectional specifies that mounts get propagated from
// the host to the container and from the container to the host
// ("rshared" in Linux).
MountPropagationBidirectional MountPropagation = 2
)
// MountPropagationValueToName is a map of valid MountPropogation values to
// their string names
var MountPropagationValueToName = map[MountPropagation]string{
MountPropagationNone: "None",
MountPropagationHostToContainer: "HostToContainer",
MountPropagationBidirectional: "Bidirectional",
}
// MountPropagationNameToValue is a map of valid MountPropogation names to
// their values
var MountPropagationNameToValue = map[string]MountPropagation{
"None": MountPropagationNone,
"HostToContainer": MountPropagationHostToContainer,
"Bidirectional": MountPropagationBidirectional,
}
// PortMappingProtocol represents an "enum" for port mapping protocol options,
// see also PortMapping.
type PortMappingProtocol int32
const (
// PortMappingProtocolTCP specifies TCP protocol
PortMappingProtocolTCP PortMappingProtocol = 0
// PortMappingProtocolUDP specifies UDP protocol
PortMappingProtocolUDP PortMappingProtocol = 1
// PortMappingProtocolSCTP specifies SCTP protocol
PortMappingProtocolSCTP PortMappingProtocol = 2
)
// PortMappingProtocolValueToName is a map of valid PortMappingProtocol values to
// their string names
var PortMappingProtocolValueToName = map[PortMappingProtocol]string{
PortMappingProtocolTCP: "TCP",
PortMappingProtocolUDP: "UDP",
PortMappingProtocolSCTP: "SCTP",
}
// PortMappingProtocolNameToValue is a map of valid PortMappingProtocol names to
// their values
var PortMappingProtocolNameToValue = map[string]PortMappingProtocol{
"TCP": PortMappingProtocolTCP,
"UDP": PortMappingProtocolUDP,
"SCTP": PortMappingProtocolSCTP,
}

View File

@@ -1,86 +0,0 @@
/*
Copyright 2019 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package v1alpha3
import (
"fmt"
"strings"
)
/*
Custom YAML (de)serialization for these types
*/
// UnmarshalYAML implements custom decoding YAML
// https://godoc.org/gopkg.in/yaml.v3
func (m *Mount) UnmarshalYAML(unmarshal func(interface{}) error) error {
// this is basically Mount, except Propagation is a string for further parsing
type MountYaml struct {
ContainerPath string `yaml:"containerPath,omitempty"`
HostPath string `yaml:"hostPath,omitempty"`
Readonly bool `yaml:"readOnly,omitempty"`
SelinuxRelabel bool `yaml:"selinuxRelabel,omitempty"`
Propagation string `yaml:"propagation,omitempty"`
}
aux := MountYaml{}
if err := unmarshal(&aux); err != nil {
return err
}
// copy over normal fields
m.ContainerPath = aux.ContainerPath
m.HostPath = aux.HostPath
m.Readonly = aux.Readonly
m.SelinuxRelabel = aux.SelinuxRelabel
// handle special field
if aux.Propagation != "" {
val, ok := MountPropagationNameToValue[aux.Propagation]
if !ok {
return fmt.Errorf("unknown propagation value: %s", aux.Propagation)
}
m.Propagation = MountPropagation(val)
}
return nil
}
// UnmarshalYAML implements custom decoding YAML
// https://godoc.org/gopkg.in/yaml.v3
func (p *PortMapping) UnmarshalYAML(unmarshal func(interface{}) error) error {
// this is basically PortMappingYaml, except Protocol is a string for further parsing
type PortMappingYaml struct {
ContainerPort int32 `yaml:"containerPort,omitempty"`
HostPort int32 `yaml:"hostPort,omitempty"`
ListenAddress string `yaml:"listenAddress,omitempty"`
Protocol string `yaml:"protocol"`
}
aux := PortMappingYaml{}
if err := unmarshal(&aux); err != nil {
return err
}
// copy normal fields
p.ContainerPort = aux.ContainerPort
p.HostPort = aux.HostPort
p.ListenAddress = aux.ListenAddress
// handle special field
if aux.Protocol != "" {
val, ok := PortMappingProtocolNameToValue[strings.ToUpper(aux.Protocol)]
if !ok {
return fmt.Errorf("unknown protocol value: %s", aux.Protocol)
}
p.Protocol = PortMappingProtocol(val)
}
return nil
}

View File

@@ -1,162 +0,0 @@
// +build !ignore_autogenerated
/*
Copyright 2019 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by deepcopy-gen. DO NOT EDIT.
package v1alpha3
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Cluster) DeepCopyInto(out *Cluster) {
*out = *in
out.TypeMeta = in.TypeMeta
if in.Nodes != nil {
in, out := &in.Nodes, &out.Nodes
*out = make([]Node, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
out.Networking = in.Networking
if in.KubeadmConfigPatches != nil {
in, out := &in.KubeadmConfigPatches, &out.KubeadmConfigPatches
*out = make([]string, len(*in))
copy(*out, *in)
}
if in.KubeadmConfigPatchesJSON6902 != nil {
in, out := &in.KubeadmConfigPatchesJSON6902, &out.KubeadmConfigPatchesJSON6902
*out = make([]PatchJSON6902, len(*in))
copy(*out, *in)
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Cluster.
func (in *Cluster) DeepCopy() *Cluster {
if in == nil {
return nil
}
out := new(Cluster)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Mount) DeepCopyInto(out *Mount) {
*out = *in
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Mount.
func (in *Mount) DeepCopy() *Mount {
if in == nil {
return nil
}
out := new(Mount)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Networking) DeepCopyInto(out *Networking) {
*out = *in
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Networking.
func (in *Networking) DeepCopy() *Networking {
if in == nil {
return nil
}
out := new(Networking)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Node) DeepCopyInto(out *Node) {
*out = *in
if in.ExtraMounts != nil {
in, out := &in.ExtraMounts, &out.ExtraMounts
*out = make([]Mount, len(*in))
copy(*out, *in)
}
if in.ExtraPortMappings != nil {
in, out := &in.ExtraPortMappings, &out.ExtraPortMappings
*out = make([]PortMapping, len(*in))
copy(*out, *in)
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Node.
func (in *Node) DeepCopy() *Node {
if in == nil {
return nil
}
out := new(Node)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *PatchJSON6902) DeepCopyInto(out *PatchJSON6902) {
*out = *in
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PatchJSON6902.
func (in *PatchJSON6902) DeepCopy() *PatchJSON6902 {
if in == nil {
return nil
}
out := new(PatchJSON6902)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *PortMapping) DeepCopyInto(out *PortMapping) {
*out = *in
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PortMapping.
func (in *PortMapping) DeepCopy() *PortMapping {
if in == nil {
return nil
}
out := new(PortMapping)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *TypeMeta) DeepCopyInto(out *TypeMeta) {
*out = *in
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TypeMeta.
func (in *TypeMeta) DeepCopy() *TypeMeta {
if in == nil {
return nil
}
out := new(TypeMeta)
in.DeepCopyInto(out)
return out
}

View File

@@ -19,7 +19,6 @@ package cluster
import (
"time"
"sigs.k8s.io/kind/pkg/apis/config/v1alpha3"
"sigs.k8s.io/kind/pkg/apis/config/v1alpha4"
internalcreate "sigs.k8s.io/kind/pkg/cluster/internal/create"
internalencoding "sigs.k8s.io/kind/pkg/internal/apis/config/encoding"
@@ -54,14 +53,6 @@ func CreateWithRawConfig(raw []byte) CreateOption {
})
}
// CreateWithV1Alpha3Config configures the cluster with a v1alpha3 config
func CreateWithV1Alpha3Config(config *v1alpha3.Cluster) CreateOption {
return createOptionAdapter(func(o *internalcreate.ClusterOptions) error {
o.Config = internalencoding.V1Alpha3ToInternal(config)
return nil
})
}
// CreateWithV1Alpha4Config configures the cluster with a v1alpha4 config
func CreateWithV1Alpha4Config(config *v1alpha4.Cluster) CreateOption {
return createOptionAdapter(func(o *internalcreate.ClusterOptions) error {

View File

@@ -1,91 +0,0 @@
/*
Copyright 2019 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package config
import (
v1alpha3 "sigs.k8s.io/kind/pkg/apis/config/v1alpha3"
)
// Convertv1alpha3 converts a v1alpha3 cluster to a cluster at the internal API version
func Convertv1alpha3(in *v1alpha3.Cluster) *Cluster {
in = in.DeepCopy() // deep copy first to avoid touching the original
out := &Cluster{
Nodes: make([]Node, len(in.Nodes)),
KubeadmConfigPatches: in.KubeadmConfigPatches,
KubeadmConfigPatchesJSON6902: make([]PatchJSON6902, len(in.KubeadmConfigPatchesJSON6902)),
}
for i := range in.Nodes {
convertv1alpha3Node(&in.Nodes[i], &out.Nodes[i])
}
convertv1alpha3Networking(&in.Networking, &out.Networking)
for i := range in.KubeadmConfigPatchesJSON6902 {
convertv1alpha3PatchJSON6902(&in.KubeadmConfigPatchesJSON6902[i], &out.KubeadmConfigPatchesJSON6902[i])
}
return out
}
func convertv1alpha3Node(in *v1alpha3.Node, out *Node) {
out.Role = NodeRole(in.Role)
out.Image = in.Image
out.ExtraMounts = make([]Mount, len(in.ExtraMounts))
out.ExtraPortMappings = make([]PortMapping, len(in.ExtraPortMappings))
for i := range in.ExtraMounts {
convertv1alpha3Mount(&in.ExtraMounts[i], &out.ExtraMounts[i])
}
for i := range in.ExtraPortMappings {
convertv1alpha3PortMapping(&in.ExtraPortMappings[i], &out.ExtraPortMappings[i])
}
}
func convertv1alpha3PatchJSON6902(in *v1alpha3.PatchJSON6902, out *PatchJSON6902) {
out.Group = in.Group
out.Version = in.Version
out.Kind = in.Kind
// NOTE: name and namespace are discarded, see the docs for the types.
out.Patch = in.Patch
}
func convertv1alpha3Networking(in *v1alpha3.Networking, out *Networking) {
out.IPFamily = ClusterIPFamily(in.IPFamily)
out.APIServerPort = in.APIServerPort
out.APIServerAddress = in.APIServerAddress
out.PodSubnet = in.PodSubnet
out.ServiceSubnet = in.ServiceSubnet
out.DisableDefaultCNI = in.DisableDefaultCNI
}
func convertv1alpha3Mount(in *v1alpha3.Mount, out *Mount) {
out.ContainerPath = in.ContainerPath
out.HostPath = in.HostPath
out.Readonly = in.Readonly
out.SelinuxRelabel = in.SelinuxRelabel
out.Propagation = MountPropagation(v1alpha3.MountPropagationValueToName[in.Propagation])
}
func convertv1alpha3PortMapping(in *v1alpha3.PortMapping, out *PortMapping) {
out.ContainerPort = in.ContainerPort
out.HostPort = in.HostPort
out.ListenAddress = in.ListenAddress
out.Protocol = PortMappingProtocol(v1alpha3.PortMappingProtocolValueToName[in.Protocol])
}

View File

@@ -17,18 +17,11 @@ limitations under the License.
package encoding
import (
"sigs.k8s.io/kind/pkg/apis/config/v1alpha3"
"sigs.k8s.io/kind/pkg/apis/config/v1alpha4"
"sigs.k8s.io/kind/pkg/internal/apis/config"
)
// V1Alpha3ToInternal converts to the internal API version
func V1Alpha3ToInternal(cluster *v1alpha3.Cluster) *config.Cluster {
v1alpha3.SetDefaultsCluster(cluster)
return config.Convertv1alpha3(cluster)
}
// V1Alpha4ToInternal converts to the internal API version
func V1Alpha4ToInternal(cluster *v1alpha4.Cluster) *config.Cluster {
v1alpha4.SetDefaultsCluster(cluster)

View File

@@ -22,7 +22,6 @@ import (
yaml "gopkg.in/yaml.v3"
"sigs.k8s.io/kind/pkg/apis/config/v1alpha3"
"sigs.k8s.io/kind/pkg/apis/config/v1alpha4"
"sigs.k8s.io/kind/pkg/errors"
@@ -75,19 +74,6 @@ func Parse(raw []byte) (*config.Cluster, error) {
}
// apply defaults for version and convert
return V1Alpha4ToInternal(cfg), nil
// handle v1alpha3
case "kind.sigs.k8s.io/v1alpha3":
if tm.Kind != "Cluster" {
return nil, errors.Errorf("unknown kind %s for apiVersion: %s", tm.Kind, tm.APIVersion)
}
// load version
cfg := &v1alpha3.Cluster{}
if err := yamlUnmarshalStrict(raw, cfg); err != nil {
return nil, errors.Wrap(err, "unable to decode config")
}
// apply defaults for version and convert
return V1Alpha3ToInternal(cfg), nil
}
// unknown apiVersion if we haven't already returned ...

View File

@@ -37,46 +37,6 @@ func TestLoadCurrent(t *testing.T) {
Path: "",
ExpectError: false,
},
{
TestName: "v1alpha3 invalid kind",
Path: "./testdata/v1alpha3/invalid-kind.yaml",
ExpectError: true,
},
{
TestName: "v1alpha3 minimal",
Path: "./testdata/v1alpha3/valid-minimal.yaml",
ExpectError: false,
},
{
TestName: "v1alpha3 config with 2 nodes",
Path: "./testdata/v1alpha3/valid-minimal-two-nodes.yaml",
ExpectError: false,
},
{
TestName: "v1alpha3 full HA",
Path: "./testdata/v1alpha3/valid-full-ha.yaml",
ExpectError: false,
},
{
TestName: "v1alpha3 many fields set",
Path: "./testdata/v1alpha3/valid-many-fields.yaml",
ExpectError: false,
},
{
TestName: "v1alpha3 config with patches",
Path: "./testdata/v1alpha3/valid-kind-patches.yaml",
ExpectError: false,
},
{
TestName: "v1alpha3 non-existent field",
Path: "./testdata/v1alpha3/invalid-bogus-field.yaml",
ExpectError: true,
},
{
TestName: "v1alpha3 bad indentation",
Path: "./testdata/v1alpha3/invalid-bad-indent.yaml",
ExpectError: true,
},
{
TestName: "v1alpha4 minimal",
Path: "./testdata/v1alpha4/valid-minimal.yaml",