mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-08-06 05:54:28 -04:00
init: add cluster version to kubernetes components
This commit is contained in:
parent
4803edd4a0
commit
25c3a8a1f3
7 changed files with 22 additions and 26 deletions
|
@ -12,7 +12,6 @@ import (
|
|||
"github.com/edgelesssys/constellation/v2/bootstrapper/internal/kubelet"
|
||||
"github.com/edgelesssys/constellation/v2/internal/constants"
|
||||
"github.com/edgelesssys/constellation/v2/internal/kubernetes"
|
||||
"github.com/edgelesssys/constellation/v2/internal/versions"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
kubeletconf "k8s.io/kubelet/config/v1beta1"
|
||||
|
@ -33,7 +32,7 @@ const (
|
|||
type KubdeadmConfiguration struct{}
|
||||
|
||||
// InitConfiguration returns a new init configuration.
|
||||
func (c *KubdeadmConfiguration) InitConfiguration(externalCloudProvider bool, k8sVersion versions.ValidK8sVersion) KubeadmInitYAML {
|
||||
func (c *KubdeadmConfiguration) InitConfiguration(externalCloudProvider bool, clusterVersion string) KubeadmInitYAML {
|
||||
var cloudProvider string
|
||||
if externalCloudProvider {
|
||||
cloudProvider = "external"
|
||||
|
@ -63,7 +62,7 @@ func (c *KubdeadmConfiguration) InitConfiguration(externalCloudProvider bool, k8
|
|||
APIVersion: kubeadm.SchemeGroupVersion.String(),
|
||||
},
|
||||
// Target kubernetes version of the control plane.
|
||||
KubernetesVersion: versions.VersionConfigs[k8sVersion].PatchVersion,
|
||||
KubernetesVersion: clusterVersion,
|
||||
// necessary to be able to access the kubeapi server through localhost
|
||||
APIServer: kubeadm.APIServer{
|
||||
ControlPlaneComponent: kubeadm.ControlPlaneComponent{
|
||||
|
|
|
@ -28,11 +28,11 @@ func TestInitConfiguration(t *testing.T) {
|
|||
config KubeadmInitYAML
|
||||
}{
|
||||
"kubeadm init config can be created": {
|
||||
config: kubeadmConfig.InitConfiguration(true, versions.Default),
|
||||
config: kubeadmConfig.InitConfiguration(true, versions.VersionConfigs[versions.Default].ClusterVersion),
|
||||
},
|
||||
"kubeadm init config with all fields can be created": {
|
||||
config: func() KubeadmInitYAML {
|
||||
c := kubeadmConfig.InitConfiguration(true, versions.Default)
|
||||
c := kubeadmConfig.InitConfiguration(true, versions.VersionConfigs[versions.Default].ClusterVersion)
|
||||
c.SetNodeIP("192.0.2.0")
|
||||
c.SetNodeName("node")
|
||||
c.SetProviderID("somecloudprovider://instance-id")
|
||||
|
@ -65,8 +65,8 @@ func TestInitConfigurationKubeadmCompatibility(t *testing.T) {
|
|||
wantErr bool
|
||||
}{
|
||||
"Kubeadm accepts version 'Latest'": {
|
||||
config: kubeadmConfig.InitConfiguration(true, versions.Default),
|
||||
expectedVersion: versions.VersionConfigs[versions.Default].PatchVersion,
|
||||
config: kubeadmConfig.InitConfiguration(true, versions.VersionConfigs[versions.Default].ClusterVersion),
|
||||
expectedVersion: versions.VersionConfigs[versions.Default].ClusterVersion,
|
||||
},
|
||||
"Kubeadm receives incompatible version": {
|
||||
config: kubeadmConfig.InitConfiguration(true, "1.19"),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue