diff --git a/cmd/config/create.go b/cmd/config/create.go index 9482739179e3..3d4e7030e36b 100644 --- a/cmd/config/create.go +++ b/cmd/config/create.go @@ -17,12 +17,12 @@ limitations under the License. package config import ( - "fmt" - "github.com/spf13/cobra" + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "sigs.k8s.io/yaml" "github.com/k0sproject/k0s/pkg/apis/k0s/v1beta1" + k0sscheme "github.com/k0sproject/k0s/pkg/client/clientset/scheme" "github.com/k0sproject/k0s/pkg/config" ) @@ -39,12 +39,19 @@ func NewCreateCmd() *cobra.Command { config.Spec.Network.NodeLocalLoadBalancing.EnvoyProxy.Image = nil } - cfg, err := yaml.Marshal(config) + var u unstructured.Unstructured + if err := k0sscheme.Scheme.Convert(config, &u, nil); err != nil { + return err + } + unstructured.RemoveNestedField(u.Object, "metadata", "creationTimestamp") + + cfg, err := yaml.Marshal(&u) if err != nil { return err } - fmt.Fprintf(cmd.OutOrStdout(), "%s", cfg) - return nil + + _, err = cmd.OutOrStdout().Write(cfg) + return err }, } cmd.Flags().BoolVar(&includeImages, "include-images", false, "include the default images in the output") diff --git a/docs/configuration.md b/docs/configuration.md index aabb31c88281..641f768ebed2 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -52,7 +52,6 @@ metadata: spec: api: address: 192.168.68.104 - externalAddress: my-lb-address.example.com k0sApiPort: 9443 port: 6443 sans: @@ -61,8 +60,6 @@ spec: extensions: helm: concurrencyLevel: 5 - charts: null - repositories: null installConfig: users: etcdUser: etcd @@ -74,21 +71,25 @@ spec: adminPort: 8133 agentPort: 8132 network: - calico: null clusterDomain: cluster.local - dualStack: {} + dualStack: + enabled: false kubeProxy: + iptables: + minSyncPeriod: 0s + syncPeriod: 0s + ipvs: + minSyncPeriod: 0s + syncPeriod: 0s + tcpFinTimeout: 0s + tcpTimeout: 0s + udpTimeout: 0s metricsBindAddress: 0.0.0.0:10249 mode: iptables kuberouter: autoMTU: true hairpin: Enabled - ipMasq: false metricsPort: 8080 - mtu: 0 - peerRouterASNs: "" - peerRouterIPs: "" - extraArgs: nodeLocalLoadBalancing: enabled: false envoyProxy: @@ -101,20 +102,10 @@ spec: scheduler: {} storage: etcd: - externalCluster: null peerAddress: 192.168.68.104 type: etcd telemetry: enabled: true - featureGates: - - name: feature_XXX - enabled: true - components: ["kubelet", "kube-api", "kube-scheduler"] - - name: feature_YYY - enabled: true - - - name: feature_ZZZ - enabled: false ``` ## `spec` Key Detail diff --git a/inttest/configchange/config_test.go b/inttest/configchange/config_test.go index eb860303c7b0..7426f849acdf 100644 --- a/inttest/configchange/config_test.go +++ b/inttest/configchange/config_test.go @@ -32,6 +32,7 @@ import ( "k8s.io/apimachinery/pkg/fields" "k8s.io/apimachinery/pkg/watch" "k8s.io/client-go/kubernetes" + "k8s.io/utils/ptr" "github.com/k0sproject/k0s/inttest/common" "github.com/stretchr/testify/suite" @@ -139,7 +140,7 @@ func (s *ConfigSuite) TestK0sGetsUp() { s.Require().NoError(err) newConfig := originalConfig.DeepCopy() newConfig.Spec.Network = v1beta1.DefaultNetwork() - newConfig.Spec.Network.KubeRouter.AutoMTU = false + newConfig.Spec.Network.KubeRouter.AutoMTU = ptr.To(false) newConfig.Spec.Network.KubeRouter.MTU = 1300 // Get the resource version for current kuberouter configmap diff --git a/pkg/apis/autopilot/v1beta2/updateconfig.go b/pkg/apis/autopilot/v1beta2/updateconfig.go index 15dbf9a7ca46..b08d3a34ad6e 100644 --- a/pkg/apis/autopilot/v1beta2/updateconfig.go +++ b/pkg/apis/autopilot/v1beta2/updateconfig.go @@ -52,7 +52,6 @@ type UpdateSpec struct { // UpdateStrategy defines the update strategy to use for this update config UpgradeStrategy UpgradeStrategy `json:"upgradeStrategy,omitempty"` // PlanSpec defines the plan spec to use for this update config - // +kubebuilder:Validation:Required PlanSpec AutopilotPlanSpec `json:"planSpec,omitempty"` } @@ -94,8 +93,7 @@ type UpgradeStrategy struct { // +kubebuilder:validation:Enum=periodic;cron Type string `json:"type,omitempty"` // Cron defines the cron expression for the cron upgrade strategy - // +kubebuilder:validation:Optional - //+kubebuilder:deprecatedversion:warning="Cron is deprecated and will be removed in 1.29" + // Deprecated: Cron is deprecated and will eventually be ignored Cron string `json:"cron,omitempty"` // Periodic defines the periodic upgrade strategy Periodic PeriodicUpgradeStrategy `json:"periodic,omitempty"` diff --git a/pkg/apis/etcd/v1beta1/types.go b/pkg/apis/etcd/v1beta1/types.go index 9d2ffd76172d..76f9359f1f66 100644 --- a/pkg/apis/etcd/v1beta1/types.go +++ b/pkg/apis/etcd/v1beta1/types.go @@ -91,16 +91,12 @@ const ( ) type JoinCondition struct { - // +kubebuilder:validation:Required // +kubebuilder:validation:Enum=Joined - Type ConditionType `json:"type"` - // +kubebuilder:validation:Required + Type ConditionType `json:"type"` Status ConditionStatus `json:"status"` // Last time the condition transitioned from one status to another. - // +optional LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty"` // Human-readable message indicating details about last transition. - // +optional Message string `json:"message,omitempty" protobuf:"bytes,6,opt,name=message"` } diff --git a/pkg/apis/helm/v1beta1/chart_types.go b/pkg/apis/helm/v1beta1/chart_types.go index b94004bc5993..3c63f75f7290 100644 --- a/pkg/apis/helm/v1beta1/chart_types.go +++ b/pkg/apis/helm/v1beta1/chart_types.go @@ -72,7 +72,6 @@ type ChartStatus struct { // +kubebuilder:subresource:status // +genclient // +genclient:onlyVerbs=create,delete,list,get,watch,update -// +groupName=helm.k0sproject.io // Chart is the Schema for the charts API type Chart struct { metav1.TypeMeta `json:",inline"` diff --git a/pkg/apis/k0s/v1beta1/api.go b/pkg/apis/k0s/v1beta1/api.go index 620c499f76ad..c771539fbd18 100644 --- a/pkg/apis/k0s/v1beta1/api.go +++ b/pkg/apis/k0s/v1beta1/api.go @@ -35,33 +35,27 @@ var _ Validateable = (*APISpec)(nil) // APISpec defines the settings for the K0s API type APISpec struct { // Address on which to connect to the API server. - // +optional Address string `json:"address,omitempty"` // The loadbalancer address (for k0s controllers running behind a loadbalancer) - // +optional ExternalAddress string `json:"externalAddress,omitempty"` // Map of key-values (strings) for any extra arguments to pass down to Kubernetes api-server process - // +optional ExtraArgs map[string]string `json:"extraArgs,omitempty"` // Custom port for k0s-api server to listen on (default: 9443) // +kubebuilder:validation:Minimum=1 // +kubebuilder:validation:Maximum=65535 // +kubebuilder:default=9443 - // +optional K0sAPIPort int `json:"k0sApiPort,omitempty"` // Custom port for kube-api server to listen on (default: 6443) // +kubebuilder:validation:Minimum=1 // +kubebuilder:validation:Maximum=65535 // +kubebuilder:default=6443 - // +optional Port int `json:"port,omitempty"` // List of additional addresses to push to API servers serving the certificate - // +optional SANs []string `json:"sans,omitempty"` } diff --git a/pkg/apis/k0s/v1beta1/calico.go b/pkg/apis/k0s/v1beta1/calico.go index c1b7d4fa5631..07edb1646aae 100644 --- a/pkg/apis/k0s/v1beta1/calico.go +++ b/pkg/apis/k0s/v1beta1/calico.go @@ -21,13 +21,14 @@ import "encoding/json" // Calico defines the calico related config options type Calico struct { // Enable wireguard-based encryption (default: false) - EnableWireguard bool `json:"wireguard"` + EnableWireguard bool `json:"wireguard,omitempty"` // Environment variables to configure Calico node (see https://docs.projectcalico.org/reference/node/configuration) EnvVars map[string]string `json:"envVars,omitempty"` // The host path for Calicos flex-volume-driver(default: /usr/libexec/k0s/kubelet-plugins/volume/exec/nodeagent~uds) - FlexVolumeDriverPath string `json:"flexVolumeDriverPath"` + // +kubebuilder:default="/usr/libexec/k0s/kubelet-plugins/volume/exec/nodeagent~uds" + FlexVolumeDriverPath string `json:"flexVolumeDriverPath,omitempty"` // Host's IP Auto-detection method for Calico (see https://docs.projectcalico.org/reference/node/configuration#ip-autodetection-methods) IPAutodetectionMethod string `json:"ipAutodetectionMethod,omitempty"` @@ -35,34 +36,36 @@ type Calico struct { // Host's IPv6 Auto-detection method for Calico IPv6AutodetectionMethod string `json:"ipV6AutodetectionMethod,omitempty"` - // MTU for overlay network (default: 0) - MTU int `json:"mtu" yaml:"mtu"` + // MTU for overlay network (default: 1450) + // +kubebuilder:default=1450 + MTU int `json:"mtu,omitempty"` // vxlan (default) or ipip - Mode string `json:"mode"` + // +kubebuilder:default=vxlan + Mode string `json:"mode,omitempty"` // Overlay Type (Always, Never or CrossSubnet) - Overlay string `json:"overlay" validate:"oneof=Always Never CrossSubnet" ` + // +kubebuilder:default=Always + Overlay string `json:"overlay,omitempty"` // The UDP port for VXLAN (default: 4789) - VxlanPort int `json:"vxlanPort"` + // +kubebuilder:default=4789 + VxlanPort int `json:"vxlanPort,omitempty"` // The virtual network ID for VXLAN (default: 4096) - VxlanVNI int `json:"vxlanVNI"` + // +kubebuilder:default=4096 + VxlanVNI int `json:"vxlanVNI,omitempty"` } // DefaultCalico returns sane defaults for calico func DefaultCalico() *Calico { return &Calico{ - Mode: "vxlan", - VxlanPort: 4789, - VxlanVNI: 4096, - MTU: 0, - EnableWireguard: false, - FlexVolumeDriverPath: "/usr/libexec/k0s/kubelet-plugins/volume/exec/nodeagent~uds", - Overlay: "Always", - IPAutodetectionMethod: "", - IPv6AutodetectionMethod: "", + Mode: "vxlan", + VxlanPort: 4789, + VxlanVNI: 4096, + MTU: 1450, + FlexVolumeDriverPath: "/usr/libexec/k0s/kubelet-plugins/volume/exec/nodeagent~uds", + Overlay: "Always", } } @@ -72,11 +75,8 @@ func (c *Calico) UnmarshalJSON(data []byte) error { c.VxlanPort = 4789 c.VxlanVNI = 4096 c.MTU = 1450 - c.EnableWireguard = false c.FlexVolumeDriverPath = "/usr/libexec/kubernetes/kubelet-plugins/volume/exec/nodeagent~uds" c.Overlay = "Always" - c.IPAutodetectionMethod = "" - c.IPv6AutodetectionMethod = "" type calico Calico jc := (*calico)(c) diff --git a/pkg/apis/k0s/v1beta1/clusterconfig_types.go b/pkg/apis/k0s/v1beta1/clusterconfig_types.go index 8afbcfe28ea1..579911480692 100644 --- a/pkg/apis/k0s/v1beta1/clusterconfig_types.go +++ b/pkg/apis/k0s/v1beta1/clusterconfig_types.go @@ -59,14 +59,12 @@ type ClusterConfigStatus struct { // Important: Run "make" to regenerate code after modifying this file } -//+kubebuilder:object:root=true -//+kubebuilder:subresource:status -//+kubebuilder:validation:Optional +// ClusterConfig is the Schema for the clusterconfigs API +// +// +kubebuilder:object:root=true +// +kubebuilder:subresource:status // +genclient // +genclient:onlyVerbs=create,delete,list,get,watch,update -// +groupName=k0s.k0sproject.io - -// ClusterConfig is the Schema for the clusterconfigs API type ClusterConfig struct { metav1.ObjectMeta `json:"metadata,omitempty"` metav1.TypeMeta `json:",omitempty,inline"` diff --git a/pkg/apis/k0s/v1beta1/controltypes.go b/pkg/apis/k0s/v1beta1/controltypes.go index af9fe1550d70..86468c3ce07c 100644 --- a/pkg/apis/k0s/v1beta1/controltypes.go +++ b/pkg/apis/k0s/v1beta1/controltypes.go @@ -28,7 +28,9 @@ type CaResponse struct { // EtcdRequest defines the etcd control api request structure type EtcdRequest struct { - Node string `json:"node"` + // +kubebuilder:validation:MinLength=1 + Node string `json:"node"` + // +kubebuilder:validation:MinLength=1 PeerAddress string `json:"peerAddress"` } diff --git a/pkg/apis/k0s/v1beta1/cplb.go b/pkg/apis/k0s/v1beta1/cplb.go index 64c7ce952d48..0689a769212c 100644 --- a/pkg/apis/k0s/v1beta1/cplb.go +++ b/pkg/apis/k0s/v1beta1/cplb.go @@ -38,17 +38,15 @@ type ControlPlaneLoadBalancingSpec struct { // Default: false // +kubebuilder:default=false // +optional - Enabled bool `json:"enabled,omitempty"` + Enabled bool `json:"enabled"` // type indicates the type of the control plane load balancer to deploy on // controller nodes. Currently, the only supported type is "Keepalived". // +kubebuilder:default=Keepalived - // +optional Type CPLBType `json:"type,omitempty"` // Keepalived contains configuration options related to the "Keepalived" type // of load balancing. - // +optional Keepalived *KeepalivedSpec `json:"keepalived,omitempty"` } @@ -80,7 +78,6 @@ type VRRPInstance struct { // VirtualIPs is the list of virtual IP address used by the VRRP instance. // Each virtual IP must be a CIDR as defined in RFC 4632 and RFC 4291. // +kubebuilder:validation:MinItems=1 - // +kubebuilder:validation:Required // +listType=set VirtualIPs []string `json:"virtualIPs"` @@ -95,14 +92,12 @@ type VRRPInstance struct { // network must not use the same VirtualRouterID. // +kubebuilder:validation:Minimum=1 // +kubebuilder:validation:Maximum=255 - // +optional VirtualRouterID int32 `json:"virtualRouterID,omitempty"` // AdvertIntervalSeconds is the advertisement interval in seconds. Defaults to 1 // second. // +kubebuilder:validation:Minimum=1 // +kubebuilder:default=1 - // +optional AdvertIntervalSeconds int32 `json:"advertIntervalSeconds,omitempty"` // AuthPass is the password for accessing VRRPD. This is not a security @@ -110,7 +105,6 @@ type VRRPInstance struct { // AuthPass must be 8 characters or less. // +kubebuilder:validation:MinLength=1 // +kubebuilder:validation:MaxLength=8 - // +kubebuilder:validation:Required AuthPass string `json:"authPass"` } @@ -171,25 +165,21 @@ type VirtualServers []VirtualServer // VirtualServer defines the configuration options for a virtual server. type VirtualServer struct { // IPAddress is the virtual IP address used by the virtual server. - // +kubebuilder:validation:Required // +kubebuilder:validation:MinLength=1 IPAddress string `json:"ipAddress"` // DelayLoop is the delay timer for check polling. DelayLoop accepts // microsecond precision. Further precision will be truncated without // warnings. Defaults to 1m. // +kubebuilder:default="1m" - // +optional DelayLoop metav1.Duration `json:"delayLoop,omitempty"` // LBAlgo is the load balancing algorithm. If not specified, defaults to rr. // Valid values are rr, wrr, lc, wlc, lblc, dh, sh, sed, nq. For further // details refer to keepalived documentation. // +kubebuilder:default=rr - // +optional LBAlgo KeepalivedLBAlgo `json:"lbAlgo,omitempty"` // LBKind is the load balancing kind. If not specified, defaults to DR. // Valid values are NAT DR TUN. For further details refer to keepalived documentation. // +kubebuilder:default=DR - // +optional LBKind KeepalivedLBKind `json:"lbKind,omitempty"` // PersistenceTimeoutSeconds specifies a timeout value for persistent // connections in seconds. PersistentTimeoutSeconds must be in the range of @@ -197,7 +187,6 @@ type VirtualServer struct { // +kubebuilder:validation:Minimum=1 // +kubebuilder:validation:Maximum=2678400 // +kubebuilder:default=360 - // +optional PersistenceTimeoutSeconds int `json:"persistenceTimeoutSeconds,omitempty"` } diff --git a/pkg/apis/k0s/v1beta1/dualstack.go b/pkg/apis/k0s/v1beta1/dualstack.go index 56583cc826ec..c65041f1d788 100644 --- a/pkg/apis/k0s/v1beta1/dualstack.go +++ b/pkg/apis/k0s/v1beta1/dualstack.go @@ -18,7 +18,9 @@ package v1beta1 // DualStack defines network configuration for ipv4\ipv6 mixed cluster setup type DualStack struct { - Enabled bool `json:"enabled,omitempty"` + // +kubebuilder:default=false + // +optional + Enabled bool `json:"enabled"` IPv6PodCIDR string `json:"IPv6podCIDR,omitempty"` IPv6ServiceCIDR string `json:"IPv6serviceCIDR,omitempty"` } diff --git a/pkg/apis/k0s/v1beta1/extensions.go b/pkg/apis/k0s/v1beta1/extensions.go index 9af1cf7f7156..591c6e4e74bf 100644 --- a/pkg/apis/k0s/v1beta1/extensions.go +++ b/pkg/apis/k0s/v1beta1/extensions.go @@ -32,24 +32,22 @@ type ClusterExtensions struct { // +optional Storage *StorageExtension `json:"storage,omitempty"` - Helm *HelmExtensions `json:"helm"` + Helm *HelmExtensions `json:"helm,omitempty"` } // Deprecated: No-op; kept for backwards compatibility. type StorageExtension struct { // Deprecated: No-op; kept for backwards compatibility. - // +optional Type string `json:"type,omitempty"` // Deprecated: No-op; kept for backwards compatibility. - // +optional - CreateDefaultStorageClass bool `json:"create_default_storage_class"` + CreateDefaultStorageClass bool `json:"create_default_storage_class,omitempty"` } // HelmExtensions specifies settings for cluster helm based extensions type HelmExtensions struct { - ConcurrencyLevel int `json:"concurrencyLevel"` - Repositories RepositoriesSettings `json:"repositories"` - Charts ChartsSettings `json:"charts"` + ConcurrencyLevel int `json:"concurrencyLevel,omitempty"` + Repositories RepositoriesSettings `json:"repositories,omitempty"` + Charts ChartsSettings `json:"charts,omitempty"` } // RepositoriesSettings repository settings @@ -103,15 +101,20 @@ func (he HelmExtensions) Validate() []error { // Chart single helm addon type Chart struct { - Name string `json:"name"` + // +kubebuilder:validation:MinLength=1 + // +kubebuilder:validation:MaxLength=53 + // +kubebuilder:validation:Pattern="[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*" + Name string `json:"name"` + // +kubebuilder:validation:MinLength=1 ChartName string `json:"chartname"` - Version string `json:"version"` - Values string `json:"values"` - TargetNS string `json:"namespace"` + Version string `json:"version,omitempty"` + Values string `json:"values,omitempty"` + // +kubebuilder:validation:MinLength=1 + TargetNS string `json:"namespace"` // Timeout specifies the timeout for how long to wait for the chart installation to finish. // A duration string is a sequence of decimal numbers, each with optional fraction and a unit suffix, such as "300ms" or "2h45m". Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h". - Timeout metav1.Duration `json:"timeout"` - Order int `json:"order"` + Timeout metav1.Duration `json:"timeout,omitempty"` + Order int `json:"order,omitempty"` } // Validate performs validation @@ -134,10 +137,10 @@ func (c Chart) Validate() error { // Repository describes single repository entry. Fields map to the CLI flags for the "helm add" command type Repository struct { // The repository name. - // +kubebuilder:Validation:Required + // +kubebuilder:validation:MinLength=1 Name string `json:"name"` // The repository URL. - // +kubebuilder:Validation:Required + // +kubebuilder:validation:MinLength=1 URL string `json:"url"` // Whether to skip TLS certificate checks when connecting to the repository. Insecure *bool `json:"insecure,omitempty"` diff --git a/pkg/apis/k0s/v1beta1/feature_gates.go b/pkg/apis/k0s/v1beta1/feature_gates.go index 3f30750b563d..d37208392423 100644 --- a/pkg/apis/k0s/v1beta1/feature_gates.go +++ b/pkg/apis/k0s/v1beta1/feature_gates.go @@ -35,6 +35,8 @@ var KubernetesComponents = []string{ } // FeatureGates collection of feature gate specs +// +listType=map +// +listMapKey=name type FeatureGates []FeatureGate // Validate validates all profiles @@ -86,10 +88,15 @@ func (fgs FeatureGates) AsSliceOfStrings(component string) []string { // FeatureGate specifies single feature gate type FeatureGate struct { // Name of the feature gate - Name string `json:"name,omitempty"` + // +kubebuilder:validation:MinLength=1 + Name string `json:"name"` // Enabled or disabled - Enabled bool `json:"enabled,omitempty"` - // Components to use feature gate on, if empty `KubernetesComponents` is used as the list + Enabled bool `json:"enabled"` + // Components to use feature gate on + // Default: kube-apiserver, kube-controller-manager, kubelet, kube-scheduler, kube-proxy + // +kubebuilder:validation:MinItems=1 + // +kubebuilder:default={kube-apiserver,kube-controller-manager,kubelet,kube-scheduler,kube-proxy} + // +listType=set Components []string `json:"components,omitempty"` } diff --git a/pkg/apis/k0s/v1beta1/images.go b/pkg/apis/k0s/v1beta1/images.go index 4530ab15f2ba..4fd1fd3311a9 100644 --- a/pkg/apis/k0s/v1beta1/images.go +++ b/pkg/apis/k0s/v1beta1/images.go @@ -32,7 +32,10 @@ import ( // ImageSpec container image settings type ImageSpec struct { - Image string `json:"image"` + // +kubebuilder:validation:MinLength=1 + Image string `json:"image"` + + // +kubebuilder:validation:Pattern="[\\w][\\w.-]{0,127}" Version string `json:"version"` } @@ -63,19 +66,18 @@ func (s *ImageSpec) URI() string { // ClusterImages sets docker images for addon components type ClusterImages struct { - Konnectivity ImageSpec `json:"konnectivity"` - PushGateway ImageSpec `json:"pushgateway"` - MetricsServer ImageSpec `json:"metricsserver"` - KubeProxy ImageSpec `json:"kubeproxy"` - CoreDNS ImageSpec `json:"coredns"` - Pause ImageSpec `json:"pause"` + Konnectivity ImageSpec `json:"konnectivity,omitempty"` + PushGateway ImageSpec `json:"pushgateway,omitempty"` + MetricsServer ImageSpec `json:"metricsserver,omitempty"` + KubeProxy ImageSpec `json:"kubeproxy,omitempty"` + CoreDNS ImageSpec `json:"coredns,omitempty"` + Pause ImageSpec `json:"pause,omitempty"` - Calico CalicoImageSpec `json:"calico"` - KubeRouter KubeRouterImageSpec `json:"kuberouter"` + Calico CalicoImageSpec `json:"calico,omitempty"` + KubeRouter KubeRouterImageSpec `json:"kuberouter,omitempty"` Repository string `json:"repository,omitempty"` - // +optional // +kubebuilder:default=IfNotPresent // +kubebuilder:validation:Enum=Always;IfNotPresent;Never DefaultPullPolicy string `json:"default_pull_policy,omitempty"` @@ -137,15 +139,15 @@ func (ci *ClusterImages) overrideImageRepositories() { // CalicoImageSpec config group for calico related image settings type CalicoImageSpec struct { - CNI ImageSpec `json:"cni"` - Node ImageSpec `json:"node"` - KubeControllers ImageSpec `json:"kubecontrollers"` + CNI ImageSpec `json:"cni,omitempty"` + Node ImageSpec `json:"node,omitempty"` + KubeControllers ImageSpec `json:"kubecontrollers,omitempty"` } // KubeRouterImageSpec config group for kube-router related images type KubeRouterImageSpec struct { - CNI ImageSpec `json:"cni"` - CNIInstaller ImageSpec `json:"cniInstaller"` + CNI ImageSpec `json:"cni,omitempty"` + CNIInstaller ImageSpec `json:"cniInstaller,omitempty"` } // DefaultClusterImages default image settings diff --git a/pkg/apis/k0s/v1beta1/konnectivity.go b/pkg/apis/k0s/v1beta1/konnectivity.go index b9870bc954e4..105d0adbc34a 100644 --- a/pkg/apis/k0s/v1beta1/konnectivity.go +++ b/pkg/apis/k0s/v1beta1/konnectivity.go @@ -29,14 +29,12 @@ type KonnectivitySpec struct { // +kubebuilder:validation:Minimum=1 // +kubebuilder:validation:Maximum=65535 // +kubebuilder:default=8133 - // +optional AdminPort int32 `json:"adminPort,omitempty"` // agent port to listen on (default 8132) // +kubebuilder:validation:Minimum=1 // +kubebuilder:validation:Maximum=65535 // +kubebuilder:default=8132 - // +optional AgentPort int32 `json:"agentPort,omitempty"` } diff --git a/pkg/apis/k0s/v1beta1/kubeproxy.go b/pkg/apis/k0s/v1beta1/kubeproxy.go index f74fd3d418c4..2a643e42644b 100644 --- a/pkg/apis/k0s/v1beta1/kubeproxy.go +++ b/pkg/apis/k0s/v1beta1/kubeproxy.go @@ -32,12 +32,12 @@ const ( // KubeProxy defines the configuration for kube-proxy type KubeProxy struct { - Disabled bool `json:"disabled,omitempty"` - Mode string `json:"mode,omitempty"` - MetricsBindAddress string `json:"metricsBindAddress,omitempty"` - IPTables *KubeProxyIPTablesConfiguration `json:"iptables,omitempty"` - IPVS *KubeProxyIPVSConfiguration `json:"ipvs,omitempty"` - NodePortAddresses []string `json:"nodePortAddresses,omitempty"` + Disabled bool `json:"disabled,omitempty"` + Mode string `json:"mode,omitempty"` + MetricsBindAddress string `json:"metricsBindAddress,omitempty"` + IPTables KubeProxyIPTablesConfiguration `json:"iptables,omitempty"` + IPVS KubeProxyIPVSConfiguration `json:"ipvs,omitempty"` + NodePortAddresses []string `json:"nodePortAddresses,omitempty"` } // KubeProxyIPTablesConfiguration contains iptables-related kube-proxy configuration @@ -66,33 +66,8 @@ type KubeProxyIPVSConfiguration struct { // DefaultKubeProxy creates the default config for kube-proxy func DefaultKubeProxy() *KubeProxy { return &KubeProxy{ - Disabled: false, Mode: "iptables", MetricsBindAddress: "0.0.0.0:10249", - IPTables: DefaultKubeProxyIPTables(), - IPVS: DefaultKubeProxyIPVS(), - } -} - -func DefaultKubeProxyIPTables() *KubeProxyIPTablesConfiguration { - return &KubeProxyIPTablesConfiguration{ - MasqueradeAll: false, - SyncPeriod: metav1.Duration{Duration: 0}, - MinSyncPeriod: metav1.Duration{Duration: 0}, - MasqueradeBit: nil, - } -} - -func DefaultKubeProxyIPVS() *KubeProxyIPVSConfiguration { - return &KubeProxyIPVSConfiguration{ - ExcludeCIDRs: nil, - Scheduler: "", - SyncPeriod: metav1.Duration{Duration: 0}, - MinSyncPeriod: metav1.Duration{Duration: 0}, - StrictARP: false, - TCPFinTimeout: metav1.Duration{Duration: 0}, - TCPTimeout: metav1.Duration{Duration: 0}, - UDPTimeout: metav1.Duration{Duration: 0}, } } diff --git a/pkg/apis/k0s/v1beta1/kuberouter.go b/pkg/apis/k0s/v1beta1/kuberouter.go index f867187ee8b5..91bea313b58c 100644 --- a/pkg/apis/k0s/v1beta1/kuberouter.go +++ b/pkg/apis/k0s/v1beta1/kuberouter.go @@ -16,33 +16,43 @@ limitations under the License. package v1beta1 +import "k8s.io/utils/ptr" + // KubeRouter defines the kube-router related config options type KubeRouter struct { // Auto-detection of used MTU (default: true) - AutoMTU bool `json:"autoMTU"` + // +kubebuilder:default=true + AutoMTU *bool `json:"autoMTU,omitempty"` // Override MTU setting (autoMTU must be set to false) - MTU int `json:"mtu"` + MTU int `json:"mtu,omitempty"` // Kube-router metrics server port. Set to 0 to disable metrics (default: 8080) - MetricsPort int `json:"metricsPort"` + MetricsPort int `json:"metricsPort,omitempty"` // Admits three values: "Enabled" enables it globally, "Allowed" allows but services must be annotated explicitly and "Disabled" // Defaults to "Enabled" // +kubebuilder:default=Enabled - Hairpin Hairpin `json:"hairpin"` - // DEPRECATED: Use hairpin instead. Activates Hairpin Mode (allow a Pod behind a Service to communicate to its own ClusterIP:Port) + Hairpin Hairpin `json:"hairpin,omitempty"` + // Deprecated: Use hairpin instead. Activates Hairpin Mode (allow a Pod behind a Service to communicate to its own ClusterIP:Port) + //+kubebuilder:deprecatedversion:warning="Use hairpin instead. Activates Hairpin Mode (allow a Pod behind a Service to communicate to its own ClusterIP:Port)" HairpinMode bool `json:"hairpinMode,omitempty"` // IP masquerade for traffic originating from the pod network, and destined outside of it (default: false) - IPMasq bool `json:"ipMasq"` + IPMasq bool `json:"ipMasq,omitempty"` // Comma-separated list of global peer addresses - // DEPRECATED: Use extraArgs with peerRouterASNs instead - PeerRouterASNs string `json:"peerRouterASNs"` + // Deprecated: Use extraArgs with peerRouterASNs instead + //+kubebuilder:deprecatedversion:warning="Use extraArgs with peerRouterASNs instead" + PeerRouterASNs string `json:"peerRouterASNs,omitempty"` // Comma-separated list of global peer ASNs - // DEPRECATED: Use extraArgs with peerRouterIPs instead - PeerRouterIPs string `json:"peerRouterIPs"` + // Deprecated: Use extraArgs with peerRouterIPs instead + //+kubebuilder:deprecatedversion:warning="Use extraArgs with peerRouterIPs instead" + PeerRouterIPs string `json:"peerRouterIPs,omitempty"` // ExtraArgs are extra arguments to pass to kube-router // Can be also used to override the default k0s managed kube-router arguments ExtraArgs map[string]string `json:"extraArgs,omitempty"` } +func (k *KubeRouter) IsAutoMTU() bool { + return k == nil || k.AutoMTU == nil || *k.AutoMTU +} + // +kubebuilder:validation:Enum=Enabled;Allowed;Disabled type Hairpin string @@ -58,7 +68,7 @@ const ( func DefaultKubeRouter() *KubeRouter { return &KubeRouter{ MTU: 0, - AutoMTU: true, + AutoMTU: ptr.To(true), MetricsPort: 8080, Hairpin: HairpinEnabled, } diff --git a/pkg/apis/k0s/v1beta1/network.go b/pkg/apis/k0s/v1beta1/network.go index 8d3e59d5afaa..cbf5184a2f48 100644 --- a/pkg/apis/k0s/v1beta1/network.go +++ b/pkg/apis/k0s/v1beta1/network.go @@ -31,30 +31,33 @@ var _ Validateable = (*Network)(nil) // Network defines the network related config options type Network struct { - Calico *Calico `json:"calico"` + Calico *Calico `json:"calico,omitempty"` DualStack DualStack `json:"dualStack,omitempty"` - KubeProxy *KubeProxy `json:"kubeProxy"` - KubeRouter *KubeRouter `json:"kuberouter"` + KubeProxy *KubeProxy `json:"kubeProxy,omitempty"` + KubeRouter *KubeRouter `json:"kuberouter,omitempty"` // NodeLocalLoadBalancing defines the configuration options related to k0s's // node-local load balancing feature. // NOTE: This feature is currently unsupported on ARMv7! - // +optional NodeLocalLoadBalancing *NodeLocalLoadBalancing `json:"nodeLocalLoadBalancing,omitempty"` // ControlPlaneLoadBalancing defines the configuration options related to k0s's // control plane load balancing feature. - // +optional ControlPlaneLoadBalancing *ControlPlaneLoadBalancingSpec `json:"controlPlaneLoadBalancing,omitempty"` // Pod network CIDR to use in the cluster - PodCIDR string `json:"podCIDR"` + // +kubebuilder:default="10.244.0.0/16" + PodCIDR string `json:"podCIDR,omitempty"` // Network provider (valid values: calico, kuberouter, or custom) - Provider string `json:"provider"` + // +kubebuilder:validation:Enum=kuberouter;calico;custom + // +kubebuilder:default=kuberouter + Provider string `json:"provider,omitempty"` // Network CIDR to use for cluster VIP services + // +kubebuilder:default="10.96.0.0/12" ServiceCIDR string `json:"serviceCIDR,omitempty"` // Cluster Domain + // +kubebuilder:default="cluster.local" ClusterDomain string `json:"clusterDomain,omitempty"` } @@ -193,13 +196,6 @@ func (n *Network) UnmarshalJSON(data []byte) error { if n.KubeProxy == nil { n.KubeProxy = DefaultKubeProxy() - } else { - if n.KubeProxy.IPTables == nil { - n.KubeProxy.IPTables = DefaultKubeProxyIPTables() - } - if n.KubeProxy.IPVS == nil { - n.KubeProxy.IPVS = DefaultKubeProxyIPVS() - } } return nil diff --git a/pkg/apis/k0s/v1beta1/network_test.go b/pkg/apis/k0s/v1beta1/network_test.go index 789486f84a4a..fc7a40e99ac1 100644 --- a/pkg/apis/k0s/v1beta1/network_test.go +++ b/pkg/apis/k0s/v1beta1/network_test.go @@ -19,6 +19,8 @@ package v1beta1 import ( "testing" + "k8s.io/utils/ptr" + "github.com/stretchr/testify/suite" ) @@ -127,7 +129,7 @@ spec: s.Equal("calico", n.Provider) s.NotNil(n.Calico) s.Equal(4789, n.Calico.VxlanPort) - s.Equal(0, n.Calico.MTU) + s.Equal(1450, n.Calico.MTU) s.Equal("vxlan", n.Calico.Mode) } @@ -151,7 +153,7 @@ spec: s.NotNil(n.KubeRouter) s.Nil(n.Calico) - s.True(n.KubeRouter.AutoMTU) + s.Equal(ptr.To(true), n.KubeRouter.AutoMTU) s.Equal(0, n.KubeRouter.MTU) s.Empty(n.KubeRouter.PeerRouterASNs) s.Empty(n.KubeRouter.PeerRouterIPs) diff --git a/pkg/apis/k0s/v1beta1/nllb.go b/pkg/apis/k0s/v1beta1/nllb.go index d46fb4227680..a1007de68a01 100644 --- a/pkg/apis/k0s/v1beta1/nllb.go +++ b/pkg/apis/k0s/v1beta1/nllb.go @@ -34,13 +34,13 @@ type NodeLocalLoadBalancing struct { // enabled indicates if node-local load balancing should be used to access // Kubernetes API servers from worker nodes. // Default: false + // +kubebuilder:default=false // +optional - Enabled bool `json:"enabled,omitempty"` + Enabled bool `json:"enabled"` // type indicates the type of the node-local load balancer to deploy on // worker nodes. Currently, the only supported type is "EnvoyProxy". // +kubebuilder:default=EnvoyProxy - // +optional Type NllbType `json:"type,omitempty"` // envoyProxy contains configuration options related to the "EnvoyProxy" type @@ -115,20 +115,17 @@ func (n *NodeLocalLoadBalancing) IsEnabled() bool { // backing implementation for node-local load balancing. type EnvoyProxy struct { // image specifies the OCI image that's being used for the Envoy Pod. - // +optional Image *ImageSpec `json:"image,omitempty"` // imagePullPolicy specifies the pull policy being used for the Envoy Pod. // Defaults to the default image pull policy. // +kubebuilder:validation:Enum=Always;Never;IfNotPresent - // +optional ImagePullPolicy corev1.PullPolicy `json:"imagePullPolicy,omitempty"` // apiServerBindPort is the port number on which to bind the Envoy load // balancer for the Kubernetes API server to on a worker's loopback // interface. This must be a valid port number, 0 < x < 65536. // Default: 7443 - // +optional // +kubebuilder:default=7443 // +kubebuilder:validation:Minimum=1 // +kubebuilder:validation:Maximum=65535 @@ -138,7 +135,6 @@ type EnvoyProxy struct { // load balancer for the konnectivity server to on a worker's loopback // interface. This must be a valid port number, 0 < x < 65536. // Default: 7132 - // +optional // +kubebuilder:default=7132 // +kubebuilder:validation:Minimum=1 // +kubebuilder:validation:Maximum=65535 diff --git a/pkg/apis/k0s/v1beta1/storage.go b/pkg/apis/k0s/v1beta1/storage.go index e1eecc2ec451..a2bdb151bed1 100644 --- a/pkg/apis/k0s/v1beta1/storage.go +++ b/pkg/apis/k0s/v1beta1/storage.go @@ -42,17 +42,19 @@ var _ Validateable = (*StorageSpec)(nil) // StorageSpec defines the storage related config options type StorageSpec struct { - Etcd *EtcdConfig `json:"etcd"` + Etcd *EtcdConfig `json:"etcd,omitempty"` Kine *KineConfig `json:"kine,omitempty"` // Type of the data store (valid values:etcd or kine) - Type string `json:"type"` + // +kubebuilder:validation:Enum=etcd;kine + // +kubebuilder:default="etcd" + Type string `json:"type,omitempty"` } // KineConfig defines the Kine related config options type KineConfig struct { // kine datasource URL - DataSource string `json:"dataSource"` + DataSource string `json:"dataSource,omitempty"` } // DefaultStorageSpec creates StorageSpec with sane defaults @@ -121,10 +123,10 @@ func (s *StorageSpec) Validate() []error { // EtcdConfig defines etcd related config options type EtcdConfig struct { // ExternalCluster defines external etcd cluster related config options - ExternalCluster *ExternalCluster `json:"externalCluster"` + ExternalCluster *ExternalCluster `json:"externalCluster,omitempty"` // Node address used for etcd cluster peering - PeerAddress string `json:"peerAddress"` + PeerAddress string `json:"peerAddress,omitempty"` // Map of key-values (strings) for any extra arguments you want to pass down to the etcd process ExtraArgs map[string]string `json:"extraArgs,omitempty"` @@ -133,19 +135,20 @@ type EtcdConfig struct { // ExternalCluster defines external etcd cluster related config options type ExternalCluster struct { // Endpoints of external etcd cluster used to connect by k0s + // +kubebuilder:validation:MinItems=1 Endpoints []string `json:"endpoints"` // EtcdPrefix is a prefix to prepend to all resource paths in etcd - EtcdPrefix string `json:"etcdPrefix"` + EtcdPrefix string `json:"etcdPrefix,omitempty"` // CaFile is the host path to a file with CA certificate - CaFile string `json:"caFile"` + CaFile string `json:"caFile,omitempty"` // ClientCertFile is the host path to a file with TLS certificate for etcd client - ClientCertFile string `json:"clientCertFile"` + ClientCertFile string `json:"clientCertFile,omitempty"` // ClientKeyFile is the host path to a file with TLS key for etcd client - ClientKeyFile string `json:"clientKeyFile"` + ClientKeyFile string `json:"clientKeyFile,omitempty"` } // DefaultEtcdConfig creates EtcdConfig with sane defaults diff --git a/pkg/apis/k0s/v1beta1/telemetry.go b/pkg/apis/k0s/v1beta1/telemetry.go index e498b743e34a..95573cd8775b 100644 --- a/pkg/apis/k0s/v1beta1/telemetry.go +++ b/pkg/apis/k0s/v1beta1/telemetry.go @@ -16,17 +16,24 @@ limitations under the License. package v1beta1 +import "k8s.io/utils/ptr" + var _ Validateable = (*ClusterTelemetry)(nil) // ClusterTelemetry holds telemetry related settings type ClusterTelemetry struct { - Enabled bool `json:"enabled"` + // +kubebuilder:default=true + Enabled *bool `json:"enabled,omitempty"` +} + +func (t *ClusterTelemetry) IsEnabled() bool { + return t == nil || t.Enabled == nil || *t.Enabled } // DefaultClusterTelemetry default settings func DefaultClusterTelemetry() *ClusterTelemetry { return &ClusterTelemetry{ - Enabled: true, + Enabled: ptr.To(true), } } diff --git a/pkg/apis/k0s/v1beta1/workerprofile.go b/pkg/apis/k0s/v1beta1/workerprofile.go index 839b98f7f6e3..6eae0b61489c 100644 --- a/pkg/apis/k0s/v1beta1/workerprofile.go +++ b/pkg/apis/k0s/v1beta1/workerprofile.go @@ -26,6 +26,8 @@ import ( var _ Validateable = (*WorkerProfiles)(nil) // WorkerProfiles profiles collection +// +listType=map +// +listMapKey=name type WorkerProfiles []WorkerProfile // Validate validates all profiles @@ -45,9 +47,7 @@ type WorkerProfile struct { Name string `json:"name"` // Worker Mapping object // +kubebuilder:validation:type=object - // +kubebuilder:pruning:PreserveUnknownFields - // +kubebuilder:validation:Optional - Config *runtime.RawExtension `json:"values"` + Config *runtime.RawExtension `json:"values,omitempty"` } var lockedFields = map[string]struct{}{ diff --git a/pkg/apis/k0s/v1beta1/zz_generated.deepcopy.go b/pkg/apis/k0s/v1beta1/zz_generated.deepcopy.go index b266fd07241b..df19e82d6a45 100644 --- a/pkg/apis/k0s/v1beta1/zz_generated.deepcopy.go +++ b/pkg/apis/k0s/v1beta1/zz_generated.deepcopy.go @@ -329,7 +329,7 @@ func (in *ClusterSpec) DeepCopyInto(out *ClusterSpec) { if in.Telemetry != nil { in, out := &in.Telemetry, &out.Telemetry *out = new(ClusterTelemetry) - **out = **in + (*in).DeepCopyInto(*out) } if in.Install != nil { in, out := &in.Install, &out.Install @@ -373,6 +373,11 @@ func (in *ClusterSpec) DeepCopy() *ClusterSpec { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ClusterTelemetry) DeepCopyInto(out *ClusterTelemetry) { *out = *in + if in.Enabled != nil { + in, out := &in.Enabled, &out.Enabled + *out = new(bool) + **out = **in + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterTelemetry. @@ -713,16 +718,8 @@ func (in *KonnectivitySpec) DeepCopy() *KonnectivitySpec { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *KubeProxy) DeepCopyInto(out *KubeProxy) { *out = *in - if in.IPTables != nil { - in, out := &in.IPTables, &out.IPTables - *out = new(KubeProxyIPTablesConfiguration) - (*in).DeepCopyInto(*out) - } - if in.IPVS != nil { - in, out := &in.IPVS, &out.IPVS - *out = new(KubeProxyIPVSConfiguration) - (*in).DeepCopyInto(*out) - } + in.IPTables.DeepCopyInto(&out.IPTables) + in.IPVS.DeepCopyInto(&out.IPVS) if in.NodePortAddresses != nil { in, out := &in.NodePortAddresses, &out.NodePortAddresses *out = make([]string, len(*in)) @@ -795,6 +792,11 @@ func (in *KubeProxyIPVSConfiguration) DeepCopy() *KubeProxyIPVSConfiguration { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *KubeRouter) DeepCopyInto(out *KubeRouter) { *out = *in + if in.AutoMTU != nil { + in, out := &in.AutoMTU, &out.AutoMTU + *out = new(bool) + **out = **in + } if in.ExtraArgs != nil { in, out := &in.ExtraArgs, &out.ExtraArgs *out = make(map[string]string, len(*in)) diff --git a/pkg/component/controller/kuberouter.go b/pkg/component/controller/kuberouter.go index 373bb16cbe31..06bdd67ba58b 100644 --- a/pkg/component/controller/kuberouter.go +++ b/pkg/component/controller/kuberouter.go @@ -120,7 +120,7 @@ func (k *KubeRouter) Reconcile(_ context.Context, clusterConfig *v1beta1.Cluster "enable-ipv4": "true", // Args from config values "enable-ipv6": fmt.Sprintf("%t", clusterConfig.Spec.Network.DualStack.Enabled), - "auto-mtu": fmt.Sprintf("%t", clusterConfig.Spec.Network.KubeRouter.AutoMTU), + "auto-mtu": fmt.Sprintf("%t", clusterConfig.Spec.Network.KubeRouter.IsAutoMTU()), "metrics-port": fmt.Sprintf("%d", clusterConfig.Spec.Network.KubeRouter.MetricsPort), "hairpin-mode": fmt.Sprintf("%t", globalHairpin), } @@ -137,7 +137,7 @@ func (k *KubeRouter) Reconcile(_ context.Context, clusterConfig *v1beta1.Cluster args.Merge(clusterConfig.Spec.Network.KubeRouter.ExtraArgs) cfg := kubeRouterConfig{ - AutoMTU: clusterConfig.Spec.Network.KubeRouter.AutoMTU, + AutoMTU: clusterConfig.Spec.Network.KubeRouter.IsAutoMTU(), MTU: clusterConfig.Spec.Network.KubeRouter.MTU, MetricsPort: clusterConfig.Spec.Network.KubeRouter.MetricsPort, IPMasq: clusterConfig.Spec.Network.KubeRouter.IPMasq, diff --git a/pkg/component/controller/kuberouter_test.go b/pkg/component/controller/kuberouter_test.go index 0d254aff2684..aac4d31b220d 100644 --- a/pkg/component/controller/kuberouter_test.go +++ b/pkg/component/controller/kuberouter_test.go @@ -32,6 +32,7 @@ import ( corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime" + "k8s.io/utils/ptr" ) func TestKubeRouterConfig(t *testing.T) { @@ -41,7 +42,7 @@ func TestKubeRouterConfig(t *testing.T) { cfg.Spec.Network.Calico = nil cfg.Spec.Network.Provider = "kuberouter" cfg.Spec.Network.KubeRouter = v1beta1.DefaultKubeRouter() - cfg.Spec.Network.KubeRouter.AutoMTU = false + cfg.Spec.Network.KubeRouter.AutoMTU = ptr.To(false) cfg.Spec.Network.KubeRouter.MTU = 1450 cfg.Spec.Network.KubeRouter.PeerRouterASNs = "12345,67890" cfg.Spec.Network.KubeRouter.PeerRouterIPs = "1.2.3.4,4.3.2.1" @@ -165,7 +166,7 @@ func TestKubeRouterManualMTUManifests(t *testing.T) { cfg.Spec.Network.Calico = nil cfg.Spec.Network.Provider = "kuberouter" cfg.Spec.Network.KubeRouter = v1beta1.DefaultKubeRouter() - cfg.Spec.Network.KubeRouter.AutoMTU = false + cfg.Spec.Network.KubeRouter.AutoMTU = ptr.To(false) cfg.Spec.Network.KubeRouter.MTU = 1234 saver := inMemorySaver{} kr := NewKubeRouter(k0sVars, saver) diff --git a/pkg/telemetry/component.go b/pkg/telemetry/component.go index 6066cc24fc2c..8bd96c3600fd 100644 --- a/pkg/telemetry/component.go +++ b/pkg/telemetry/component.go @@ -96,7 +96,7 @@ func (c *Component) Stop() error { // Reconcile detects changes in configuration and applies them to the component func (c *Component) Reconcile(ctx context.Context, clusterCfg *v1beta1.ClusterConfig) error { logrus.Debug("reconcile method called for: Telemetry") - if !clusterCfg.Spec.Telemetry.Enabled { + if !clusterCfg.Spec.Telemetry.IsEnabled() { return c.Stop() } if c.stopCh != nil { diff --git a/static/manifests/autopilot/CustomResourceDefinition/autopilot.k0sproject.io_updateconfigs.yaml b/static/manifests/autopilot/CustomResourceDefinition/autopilot.k0sproject.io_updateconfigs.yaml index 1cacdb0da367..970fc643c3fc 100644 --- a/static/manifests/autopilot/CustomResourceDefinition/autopilot.k0sproject.io_updateconfigs.yaml +++ b/static/manifests/autopilot/CustomResourceDefinition/autopilot.k0sproject.io_updateconfigs.yaml @@ -244,8 +244,9 @@ spec: this update config properties: cron: - description: Cron defines the cron expression for the cron upgrade - strategy + description: |- + Cron defines the cron expression for the cron upgrade strategy + Deprecated: Cron is deprecated and will eventually be ignored type: string periodic: description: Periodic defines the periodic upgrade strategy diff --git a/static/manifests/k0s/CustomResourceDefinition/k0s.k0sproject.io_clusterconfigs.yaml b/static/manifests/k0s/CustomResourceDefinition/k0s.k0sproject.io_clusterconfigs.yaml index f3bf11155bba..1dd7eb803c7d 100644 --- a/static/manifests/k0s/CustomResourceDefinition/k0s.k0sproject.io_clusterconfigs.yaml +++ b/static/manifests/k0s/CustomResourceDefinition/k0s.k0sproject.io_clusterconfigs.yaml @@ -99,10 +99,15 @@ spec: description: Chart single helm addon properties: chartname: + minLength: 1 type: string name: + maxLength: 53 + minLength: 1 + pattern: '[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*' type: string namespace: + minLength: 1 type: string order: type: integer @@ -115,6 +120,10 @@ spec: type: string version: type: string + required: + - chartname + - name + - namespace type: object type: array concurrencyLevel: @@ -143,16 +152,21 @@ spec: type: string name: description: The repository name. + minLength: 1 type: string password: description: Password for Basic HTTP authentication. type: string url: description: The repository URL. + minLength: 1 type: string username: description: Username for Basic HTTP authentication. type: string + required: + - name + - url type: object type: array type: object @@ -175,19 +189,35 @@ spec: description: FeatureGate specifies single feature gate properties: components: - description: Components to use feature gate on, if empty `KubernetesComponents` - is used as the list + default: + - kube-apiserver + - kube-controller-manager + - kubelet + - kube-scheduler + - kube-proxy + description: |- + Components to use feature gate on + Default: kube-apiserver, kube-controller-manager, kubelet, kube-scheduler, kube-proxy items: type: string + minItems: 1 type: array + x-kubernetes-list-type: set enabled: description: Enabled or disabled type: boolean name: description: Name of the feature gate + minLength: 1 type: string + required: + - enabled + - name type: object type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map images: description: ClusterImages sets docker images for addon components properties: @@ -199,34 +229,54 @@ spec: description: ImageSpec container image settings properties: image: + minLength: 1 type: string version: + pattern: '[\w][\w.-]{0,127}' type: string + required: + - image + - version type: object kubecontrollers: description: ImageSpec container image settings properties: image: + minLength: 1 type: string version: + pattern: '[\w][\w.-]{0,127}' type: string + required: + - image + - version type: object node: description: ImageSpec container image settings properties: image: + minLength: 1 type: string version: + pattern: '[\w][\w.-]{0,127}' type: string + required: + - image + - version type: object type: object coredns: description: ImageSpec container image settings properties: image: + minLength: 1 type: string version: + pattern: '[\w][\w.-]{0,127}' type: string + required: + - image + - version type: object default_pull_policy: default: IfNotPresent @@ -239,17 +289,27 @@ spec: description: ImageSpec container image settings properties: image: + minLength: 1 type: string version: + pattern: '[\w][\w.-]{0,127}' type: string + required: + - image + - version type: object kubeproxy: description: ImageSpec container image settings properties: image: + minLength: 1 type: string version: + pattern: '[\w][\w.-]{0,127}' type: string + required: + - image + - version type: object kuberouter: description: KubeRouterImageSpec config group for kube-router @@ -259,42 +319,67 @@ spec: description: ImageSpec container image settings properties: image: + minLength: 1 type: string version: + pattern: '[\w][\w.-]{0,127}' type: string + required: + - image + - version type: object cniInstaller: description: ImageSpec container image settings properties: image: + minLength: 1 type: string version: + pattern: '[\w][\w.-]{0,127}' type: string + required: + - image + - version type: object type: object metricsserver: description: ImageSpec container image settings properties: image: + minLength: 1 type: string version: + pattern: '[\w][\w.-]{0,127}' type: string + required: + - image + - version type: object pause: description: ImageSpec container image settings properties: image: + minLength: 1 type: string version: + pattern: '[\w][\w.-]{0,127}' type: string + required: + - image + - version type: object pushgateway: description: ImageSpec container image settings properties: image: + minLength: 1 type: string version: + pattern: '[\w][\w.-]{0,127}' type: string + required: + - image + - version type: object repository: type: string @@ -349,6 +434,7 @@ spec: (see https://docs.projectcalico.org/reference/node/configuration) type: object flexVolumeDriverPath: + default: /usr/libexec/k0s/kubelet-plugins/volume/exec/nodeagent~uds description: 'The host path for Calicos flex-volume-driver(default: /usr/libexec/k0s/kubelet-plugins/volume/exec/nodeagent~uds)' type: string @@ -360,18 +446,23 @@ spec: description: Host's IPv6 Auto-detection method for Calico type: string mode: + default: vxlan description: vxlan (default) or ipip type: string mtu: - description: 'MTU for overlay network (default: 0)' + default: 1450 + description: 'MTU for overlay network (default: 1450)' type: integer overlay: + default: Always description: Overlay Type (Always, Never or CrossSubnet) type: string vxlanPort: + default: 4789 description: 'The UDP port for VXLAN (default: 4789)' type: integer vxlanVNI: + default: 4096 description: 'The virtual network ID for VXLAN (default: 4096)' type: integer wireguard: @@ -380,6 +471,7 @@ spec: type: boolean type: object clusterDomain: + default: cluster.local description: Cluster Domain type: string controlPlaneLoadBalancing: @@ -535,6 +627,7 @@ spec: IPv6serviceCIDR: type: string enabled: + default: false type: boolean type: object kubeProxy: @@ -597,6 +690,7 @@ spec: options properties: autoMTU: + default: true description: 'Auto-detection of used MTU (default: true)' type: boolean extraArgs: @@ -617,7 +711,7 @@ spec: - Disabled type: string hairpinMode: - description: 'DEPRECATED: Use hairpin instead. Activates Hairpin + description: 'Deprecated: Use hairpin instead. Activates Hairpin Mode (allow a Pod behind a Service to communicate to its own ClusterIP:Port)' type: boolean @@ -636,12 +730,12 @@ spec: peerRouterASNs: description: |- Comma-separated list of global peer addresses - DEPRECATED: Use extraArgs with peerRouterASNs instead + Deprecated: Use extraArgs with peerRouterASNs instead type: string peerRouterIPs: description: |- Comma-separated list of global peer ASNs - DEPRECATED: Use extraArgs with peerRouterIPs instead + Deprecated: Use extraArgs with peerRouterIPs instead type: string type: object nodeLocalLoadBalancing: @@ -651,6 +745,7 @@ spec: NOTE: This feature is currently unsupported on ARMv7! properties: enabled: + default: false description: |- enabled indicates if node-local load balancing should be used to access Kubernetes API servers from worker nodes. @@ -677,9 +772,14 @@ spec: used for the Envoy Pod. properties: image: + minLength: 1 type: string version: + pattern: '[\w][\w.-]{0,127}' type: string + required: + - image + - version type: object imagePullPolicy: description: |- @@ -712,13 +812,20 @@ spec: type: string type: object podCIDR: + default: 10.244.0.0/16 description: Pod network CIDR to use in the cluster type: string provider: + default: kuberouter description: 'Network provider (valid values: calico, kuberouter, or custom)' + enum: + - kuberouter + - calico + - custom type: string serviceCIDR: + default: 10.96.0.0/12 description: Network CIDR to use for cluster VIP services type: string type: object @@ -759,11 +866,14 @@ spec: connect by k0s items: type: string + minItems: 1 type: array etcdPrefix: description: EtcdPrefix is a prefix to prepend to all resource paths in etcd type: string + required: + - endpoints type: object extraArgs: additionalProperties: @@ -783,13 +893,18 @@ spec: type: string type: object type: + default: etcd description: Type of the data store (valid values:etcd or kine) + enum: + - etcd + - kine type: string type: object telemetry: description: ClusterTelemetry holds telemetry related settings properties: enabled: + default: true type: boolean type: object workerProfiles: @@ -805,8 +920,13 @@ spec: description: Worker Mapping object type: object x-kubernetes-preserve-unknown-fields: true + required: + - name type: object type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map type: object status: description: ClusterConfigStatus defines the observed state of ClusterConfig