Files
kamaji/internal/kubeadm/addon.go
Dario Tranchitella 66d96a138d feat(deps): bump sigs.k8s.io/controller-runtime from 0.18.5 to 0.19.0 (#551)
* feat(deps): bump sigs.k8s.io/controller-runtime from 0.18.5 to 0.19.0

Signed-off-by: Dario Tranchitella <dario@tranchitella.eu>

* feat: bumping up k8s supported version to v1.30.0

Signed-off-by: Dario Tranchitella <dario@tranchitella.eu>

* feat(deps): aligning code to controlle-runtime v0.19.0

Signed-off-by: Dario Tranchitella <dario@tranchitella.eu>

* docs: clastix subscription plans info

Signed-off-by: Dario Tranchitella <dario@tranchitella.eu>

* chore: bumping up controller-gen to v0.16.1

* chore(kustomize): updating manifests for k8s v1.31.0 support

* chore(helm): updating manifests for k8s v1.31.0 support

* docs(api): updating api for k8s v1.31.0 support

Signed-off-by: Dario Tranchitella <dario@tranchitella.eu>

* fix(test): worker nodes join support from v1.29 onwards

Signed-off-by: Dario Tranchitella <dario@tranchitella.eu>

* chore(ci): disabling swap

Signed-off-by: Dario Tranchitella <dario@tranchitella.eu>

---------

Signed-off-by: Dario Tranchitella <dario@tranchitella.eu>
2024-08-20 17:37:18 +02:00

59 lines
2.2 KiB
Go

// Copyright 2022 Clastix Labs
// SPDX-License-Identifier: Apache-2.0
package kubeadm
import (
"bytes"
"k8s.io/client-go/kubernetes"
"k8s.io/kubernetes/cmd/kubeadm/app/constants"
"k8s.io/kubernetes/cmd/kubeadm/app/phases/addons/dns"
"k8s.io/kubernetes/cmd/kubeadm/app/phases/addons/proxy"
)
const (
KubeSystemNamespace = "kube-system"
KubeProxyName = constants.KubeProxy
KubeProxyClusterRoleBindingName = constants.KubeProxyClusterRoleBindingName
KubeProxyServiceAccountName = proxy.KubeProxyServiceAccountName
KubeProxyConfigMapRoleName = proxy.KubeProxyConfigMapRoleName
KubeProxyConfigMap = constants.KubeProxyConfigMap
CoreDNSName = constants.CoreDNSDeploymentName
CoreDNSServiceName = "kube-dns"
CoreDNSClusterRoleName = "system:coredns"
CoreDNSClusterRoleBindingName = "system:coredns"
)
func AddCoreDNS(client kubernetes.Interface, config *Configuration) ([]byte, error) {
// We're passing the values from the parameters here because they wouldn't be hashed by the YAML encoder:
// the struct kubeadm.ClusterConfiguration hasn't struct tags, and it wouldn't be hashed properly.
if opts := config.Parameters.CoreDNSOptions; opts != nil {
config.InitConfiguration.DNS.ImageRepository = opts.Repository
config.InitConfiguration.DNS.ImageTag = opts.Tag
}
b := bytes.NewBuffer([]byte{})
if err := dns.EnsureDNSAddon(&config.InitConfiguration.ClusterConfiguration, client, "", b, true); err != nil {
return nil, err
}
return b.Bytes(), nil
}
func AddKubeProxy(client kubernetes.Interface, config *Configuration) ([]byte, error) {
// This is a workaround since the function EnsureProxyAddon is picking repository and tag from the InitConfiguration
// struct, although is counterintuitive
config.InitConfiguration.ClusterConfiguration.CIImageRepository = config.Parameters.KubeProxyOptions.Repository
config.InitConfiguration.KubernetesVersion = config.Parameters.KubeProxyOptions.Tag
b := bytes.NewBuffer([]byte{})
if err := proxy.EnsureProxyAddon(&config.InitConfiguration.ClusterConfiguration, &config.InitConfiguration.LocalAPIEndpoint, client, b, true); err != nil {
return nil, err
}
return b.Bytes(), nil
}