From fc3508437971132e2e1fc029244f1eedd8a06c01 Mon Sep 17 00:00:00 2001 From: katexochen <49727155+katexochen@users.noreply.github.com> Date: Tue, 28 Jun 2022 18:23:24 +0200 Subject: [PATCH] Move kubernetes package into internal --- coordinator/cloudprovider/azure/autoscaler.go | 2 +- .../cloudprovider/azure/autoscaler_test.go | 2 +- coordinator/cloudprovider/azure/ccm.go | 2 +- coordinator/cloudprovider/azure/ccm_test.go | 2 +- coordinator/cloudprovider/gcp/autoscaler.go | 2 +- coordinator/cloudprovider/gcp/ccm.go | 2 +- coordinator/cloudprovider/gcp/ccm_test.go | 2 +- coordinator/cloudprovider/qemu/autoscaler.go | 2 +- coordinator/cloudprovider/qemu/ccm.go | 2 +- coordinator/cmd/coordinator/main.go | 6 +-- coordinator/internal/initserver/initserver.go | 2 +- .../kubernetes/cloud_provider.go | 34 +++++++------- .../kubernetes/k8sapi/install.go | 0 .../kubernetes/k8sapi/install_test.go | 0 .../kubernetes/k8sapi/joinargs.go | 0 .../kubernetes/k8sapi/joinargs_test.go | 0 .../kubernetes/k8sapi/kubeadm_config.go | 2 +- .../kubernetes/k8sapi/kubeadm_config_test.go | 0 .../k8sapi/kubectl/client/client.go | 2 +- .../k8sapi/kubectl/client/client_test.go | 2 +- .../k8sapi/kubectl/client/restclient.go | 0 .../k8sapi/kubectl/client/restclient_test.go | 0 .../kubernetes/k8sapi/kubectl/generator.go | 2 +- .../kubernetes/k8sapi/kubectl/kubectl.go | 2 +- .../kubernetes/k8sapi/kubectl/kubectl_test.go | 2 +- .../k8sapi/resources/access_manager.go | 0 .../k8sapi/resources/access_manager_test.go | 0 .../kubernetes/k8sapi/resources/activation.go | 0 .../k8sapi/resources/activation_test.go | 0 .../k8sapi/resources/auditpolicy.go | 0 .../k8sapi/resources/auditpolicy_test.go | 0 .../resources/cloud_controller_manager.go | 0 .../cloud_controller_manager_test.go | 0 .../k8sapi/resources/cloudnodemanager.go | 0 .../k8sapi/resources/cloudnodemanager_test.go | 0 .../k8sapi/resources/cluster_autoscaler.go | 0 .../resources/cluster_autoscaler_test.go | 0 .../kubernetes/k8sapi/resources/configmaps.go | 0 .../k8sapi/resources/configmaps_test.go | 0 .../k8sapi/resources/image_pull_secret.go | 0 .../resources/image_pull_secret_test.go | 0 .../kubernetes/k8sapi/resources/kms.go | 0 .../kubernetes/k8sapi/resources/kms_test.go | 0 .../kubernetes/k8sapi/resources/marshal.go | 0 .../k8sapi/resources/marshal_test.go | 0 .../kubernetes/k8sapi/resources/secrets.go | 0 .../k8sapi/resources/secrets_test.go | 0 .../kubernetes/k8sapi/systemd.go | 0 .../{ => internal}/kubernetes/k8sapi/util.go | 2 +- .../kubernetes/k8sapi/versions.go | 0 .../{ => internal}/kubernetes/k8sutil.go | 4 +- .../{ => internal}/kubernetes/kubeconfig.go | 0 .../kubernetes/kubeconfig_test.go | 0 .../{ => internal}/kubernetes/kubernetes.go | 29 +++++++----- .../kubernetes/kubernetes_test.go | 44 ++++++------------- docs/upgrade-kubernetes.md | 2 +- 56 files changed, 71 insertions(+), 82 deletions(-) rename coordinator/{ => internal}/kubernetes/cloud_provider.go (85%) rename coordinator/{ => internal}/kubernetes/k8sapi/install.go (100%) rename coordinator/{ => internal}/kubernetes/k8sapi/install_test.go (100%) rename coordinator/{ => internal}/kubernetes/k8sapi/joinargs.go (100%) rename coordinator/{ => internal}/kubernetes/k8sapi/joinargs_test.go (100%) rename coordinator/{ => internal}/kubernetes/k8sapi/kubeadm_config.go (99%) rename coordinator/{ => internal}/kubernetes/k8sapi/kubeadm_config_test.go (100%) rename coordinator/{ => internal}/kubernetes/k8sapi/kubectl/client/client.go (96%) rename coordinator/{ => internal}/kubernetes/k8sapi/kubectl/client/client_test.go (98%) rename coordinator/{ => internal}/kubernetes/k8sapi/kubectl/client/restclient.go (100%) rename coordinator/{ => internal}/kubernetes/k8sapi/kubectl/client/restclient_test.go (100%) rename coordinator/{ => internal}/kubernetes/k8sapi/kubectl/generator.go (72%) rename coordinator/{ => internal}/kubernetes/k8sapi/kubectl/kubectl.go (95%) rename coordinator/{ => internal}/kubernetes/k8sapi/kubectl/kubectl_test.go (96%) rename coordinator/{ => internal}/kubernetes/k8sapi/resources/access_manager.go (100%) rename coordinator/{ => internal}/kubernetes/k8sapi/resources/access_manager_test.go (100%) rename coordinator/{ => internal}/kubernetes/k8sapi/resources/activation.go (100%) rename coordinator/{ => internal}/kubernetes/k8sapi/resources/activation_test.go (100%) rename coordinator/{ => internal}/kubernetes/k8sapi/resources/auditpolicy.go (100%) rename coordinator/{ => internal}/kubernetes/k8sapi/resources/auditpolicy_test.go (100%) rename coordinator/{ => internal}/kubernetes/k8sapi/resources/cloud_controller_manager.go (100%) rename coordinator/{ => internal}/kubernetes/k8sapi/resources/cloud_controller_manager_test.go (100%) rename coordinator/{ => internal}/kubernetes/k8sapi/resources/cloudnodemanager.go (100%) rename coordinator/{ => internal}/kubernetes/k8sapi/resources/cloudnodemanager_test.go (100%) rename coordinator/{ => internal}/kubernetes/k8sapi/resources/cluster_autoscaler.go (100%) rename coordinator/{ => internal}/kubernetes/k8sapi/resources/cluster_autoscaler_test.go (100%) rename coordinator/{ => internal}/kubernetes/k8sapi/resources/configmaps.go (100%) rename coordinator/{ => internal}/kubernetes/k8sapi/resources/configmaps_test.go (100%) rename coordinator/{ => internal}/kubernetes/k8sapi/resources/image_pull_secret.go (100%) rename coordinator/{ => internal}/kubernetes/k8sapi/resources/image_pull_secret_test.go (100%) rename coordinator/{ => internal}/kubernetes/k8sapi/resources/kms.go (100%) rename coordinator/{ => internal}/kubernetes/k8sapi/resources/kms_test.go (100%) rename coordinator/{ => internal}/kubernetes/k8sapi/resources/marshal.go (100%) rename coordinator/{ => internal}/kubernetes/k8sapi/resources/marshal_test.go (100%) rename coordinator/{ => internal}/kubernetes/k8sapi/resources/secrets.go (100%) rename coordinator/{ => internal}/kubernetes/k8sapi/resources/secrets_test.go (100%) rename coordinator/{ => internal}/kubernetes/k8sapi/systemd.go (100%) rename coordinator/{ => internal}/kubernetes/k8sapi/util.go (99%) rename coordinator/{ => internal}/kubernetes/k8sapi/versions.go (100%) rename coordinator/{ => internal}/kubernetes/k8sutil.go (89%) rename coordinator/{ => internal}/kubernetes/kubeconfig.go (100%) rename coordinator/{ => internal}/kubernetes/kubeconfig_test.go (100%) rename coordinator/{ => internal}/kubernetes/kubernetes.go (93%) rename coordinator/{ => internal}/kubernetes/kubernetes_test.go (94%) diff --git a/coordinator/cloudprovider/azure/autoscaler.go b/coordinator/cloudprovider/azure/autoscaler.go index 8c0295915..246ca6cd9 100644 --- a/coordinator/cloudprovider/azure/autoscaler.go +++ b/coordinator/cloudprovider/azure/autoscaler.go @@ -1,7 +1,7 @@ package azure import ( - "github.com/edgelesssys/constellation/coordinator/kubernetes/k8sapi/resources" + "github.com/edgelesssys/constellation/coordinator/internal/kubernetes/k8sapi/resources" "github.com/edgelesssys/constellation/internal/azureshared" k8s "k8s.io/api/core/v1" meta "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/coordinator/cloudprovider/azure/autoscaler_test.go b/coordinator/cloudprovider/azure/autoscaler_test.go index 0a6963d5d..ce27c6761 100644 --- a/coordinator/cloudprovider/azure/autoscaler_test.go +++ b/coordinator/cloudprovider/azure/autoscaler_test.go @@ -3,7 +3,7 @@ package azure import ( "testing" - "github.com/edgelesssys/constellation/coordinator/kubernetes/k8sapi/resources" + "github.com/edgelesssys/constellation/coordinator/internal/kubernetes/k8sapi/resources" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" k8s "k8s.io/api/core/v1" diff --git a/coordinator/cloudprovider/azure/ccm.go b/coordinator/cloudprovider/azure/ccm.go index 5a39354c2..cec1f2870 100644 --- a/coordinator/cloudprovider/azure/ccm.go +++ b/coordinator/cloudprovider/azure/ccm.go @@ -5,7 +5,7 @@ import ( "encoding/json" "github.com/edgelesssys/constellation/coordinator/cloudprovider" - "github.com/edgelesssys/constellation/coordinator/kubernetes/k8sapi/resources" + "github.com/edgelesssys/constellation/coordinator/internal/kubernetes/k8sapi/resources" "github.com/edgelesssys/constellation/internal/azureshared" "github.com/edgelesssys/constellation/internal/cloud/metadata" k8s "k8s.io/api/core/v1" diff --git a/coordinator/cloudprovider/azure/ccm_test.go b/coordinator/cloudprovider/azure/ccm_test.go index c38af2d73..a6c7cef85 100644 --- a/coordinator/cloudprovider/azure/ccm_test.go +++ b/coordinator/cloudprovider/azure/ccm_test.go @@ -5,7 +5,7 @@ import ( "errors" "testing" - "github.com/edgelesssys/constellation/coordinator/kubernetes/k8sapi/resources" + "github.com/edgelesssys/constellation/coordinator/internal/kubernetes/k8sapi/resources" "github.com/edgelesssys/constellation/internal/cloud/metadata" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" diff --git a/coordinator/cloudprovider/gcp/autoscaler.go b/coordinator/cloudprovider/gcp/autoscaler.go index d54b4fb97..d0616f02c 100644 --- a/coordinator/cloudprovider/gcp/autoscaler.go +++ b/coordinator/cloudprovider/gcp/autoscaler.go @@ -1,7 +1,7 @@ package gcp import ( - "github.com/edgelesssys/constellation/coordinator/kubernetes/k8sapi/resources" + "github.com/edgelesssys/constellation/coordinator/internal/kubernetes/k8sapi/resources" "github.com/edgelesssys/constellation/internal/cloud/metadata" k8s "k8s.io/api/core/v1" ) diff --git a/coordinator/cloudprovider/gcp/ccm.go b/coordinator/cloudprovider/gcp/ccm.go index 7eaeaa02d..061333b25 100644 --- a/coordinator/cloudprovider/gcp/ccm.go +++ b/coordinator/cloudprovider/gcp/ccm.go @@ -7,7 +7,7 @@ import ( "strings" "github.com/edgelesssys/constellation/coordinator/cloudprovider" - "github.com/edgelesssys/constellation/coordinator/kubernetes/k8sapi/resources" + "github.com/edgelesssys/constellation/coordinator/internal/kubernetes/k8sapi/resources" "github.com/edgelesssys/constellation/internal/cloud/metadata" "github.com/edgelesssys/constellation/internal/gcpshared" k8s "k8s.io/api/core/v1" diff --git a/coordinator/cloudprovider/gcp/ccm_test.go b/coordinator/cloudprovider/gcp/ccm_test.go index 25880ad54..95363284f 100644 --- a/coordinator/cloudprovider/gcp/ccm_test.go +++ b/coordinator/cloudprovider/gcp/ccm_test.go @@ -5,7 +5,7 @@ import ( "encoding/json" "testing" - "github.com/edgelesssys/constellation/coordinator/kubernetes/k8sapi/resources" + "github.com/edgelesssys/constellation/coordinator/internal/kubernetes/k8sapi/resources" "github.com/edgelesssys/constellation/internal/cloud/metadata" "github.com/edgelesssys/constellation/internal/gcpshared" "github.com/stretchr/testify/assert" diff --git a/coordinator/cloudprovider/qemu/autoscaler.go b/coordinator/cloudprovider/qemu/autoscaler.go index 84b7d34df..9e4995337 100644 --- a/coordinator/cloudprovider/qemu/autoscaler.go +++ b/coordinator/cloudprovider/qemu/autoscaler.go @@ -1,7 +1,7 @@ package qemu import ( - "github.com/edgelesssys/constellation/coordinator/kubernetes/k8sapi/resources" + "github.com/edgelesssys/constellation/coordinator/internal/kubernetes/k8sapi/resources" "github.com/edgelesssys/constellation/internal/cloud/metadata" k8s "k8s.io/api/core/v1" ) diff --git a/coordinator/cloudprovider/qemu/ccm.go b/coordinator/cloudprovider/qemu/ccm.go index d8b76a9b2..3fa3de92c 100644 --- a/coordinator/cloudprovider/qemu/ccm.go +++ b/coordinator/cloudprovider/qemu/ccm.go @@ -3,7 +3,7 @@ package qemu import ( "context" - "github.com/edgelesssys/constellation/coordinator/kubernetes/k8sapi/resources" + "github.com/edgelesssys/constellation/coordinator/internal/kubernetes/k8sapi/resources" "github.com/edgelesssys/constellation/internal/cloud/metadata" k8s "k8s.io/api/core/v1" ) diff --git a/coordinator/cmd/coordinator/main.go b/coordinator/cmd/coordinator/main.go index a697199c5..2b4864680 100644 --- a/coordinator/cmd/coordinator/main.go +++ b/coordinator/cmd/coordinator/main.go @@ -14,9 +14,9 @@ import ( qemucloud "github.com/edgelesssys/constellation/coordinator/cloudprovider/qemu" "github.com/edgelesssys/constellation/coordinator/config" "github.com/edgelesssys/constellation/coordinator/core" - "github.com/edgelesssys/constellation/coordinator/kubernetes" - "github.com/edgelesssys/constellation/coordinator/kubernetes/k8sapi" - "github.com/edgelesssys/constellation/coordinator/kubernetes/k8sapi/kubectl" + "github.com/edgelesssys/constellation/coordinator/internal/kubernetes" + "github.com/edgelesssys/constellation/coordinator/internal/kubernetes/k8sapi" + "github.com/edgelesssys/constellation/coordinator/internal/kubernetes/k8sapi/kubectl" "github.com/edgelesssys/constellation/coordinator/logging" "github.com/edgelesssys/constellation/internal/atls" "github.com/edgelesssys/constellation/internal/attestation/azure" diff --git a/coordinator/internal/initserver/initserver.go b/coordinator/internal/initserver/initserver.go index 014c310d4..fc5d90624 100644 --- a/coordinator/internal/initserver/initserver.go +++ b/coordinator/internal/initserver/initserver.go @@ -10,7 +10,7 @@ import ( "github.com/edgelesssys/constellation/coordinator/config" "github.com/edgelesssys/constellation/coordinator/diskencryption" "github.com/edgelesssys/constellation/coordinator/initproto" - "github.com/edgelesssys/constellation/coordinator/kubernetes" + "github.com/edgelesssys/constellation/coordinator/internal/kubernetes" "github.com/edgelesssys/constellation/coordinator/nodestate" "github.com/edgelesssys/constellation/coordinator/role" "github.com/edgelesssys/constellation/coordinator/util" diff --git a/coordinator/kubernetes/cloud_provider.go b/coordinator/internal/kubernetes/cloud_provider.go similarity index 85% rename from coordinator/kubernetes/cloud_provider.go rename to coordinator/internal/kubernetes/cloud_provider.go index 139d22ff2..c1e630398 100644 --- a/coordinator/kubernetes/cloud_provider.go +++ b/coordinator/internal/kubernetes/cloud_provider.go @@ -3,18 +3,18 @@ package kubernetes import ( "context" - "github.com/edgelesssys/constellation/coordinator/cloudprovider/cloudtypes" - "github.com/edgelesssys/constellation/coordinator/kubernetes/k8sapi/resources" + "github.com/edgelesssys/constellation/coordinator/internal/kubernetes/k8sapi/resources" "github.com/edgelesssys/constellation/coordinator/role" + "github.com/edgelesssys/constellation/internal/cloud/metadata" k8s "k8s.io/api/core/v1" ) // ProviderMetadata implementers read/write cloud provider metadata. type ProviderMetadata interface { // List retrieves all instances belonging to the current Constellation. - List(ctx context.Context) ([]cloudtypes.Instance, error) + List(ctx context.Context) ([]metadata.InstanceMetadata, error) // Self retrieves the current instance. - Self(ctx context.Context) (cloudtypes.Instance, error) + Self(ctx context.Context) (metadata.InstanceMetadata, error) // GetSubnetworkCIDR retrieves the subnetwork CIDR for the current instance. GetSubnetworkCIDR(ctx context.Context) (string, error) // SupportsLoadBalancer returns true if the cloud provider supports load balancers. @@ -22,7 +22,7 @@ type ProviderMetadata interface { // GetLoadBalancerIP retrieves the load balancer IP. GetLoadBalancerIP(ctx context.Context) (string, error) // GetInstance retrieves an instance using its providerID. - GetInstance(ctx context.Context, providerID string) (cloudtypes.Instance, error) + GetInstance(ctx context.Context, providerID string) (metadata.InstanceMetadata, error) // SignalRole signals the constellation role via cloud provider metadata (if supported by the CSP and deployment type, otherwise does nothing). SignalRole(ctx context.Context, role role.Role) error // SetVPNIP stores the internally used VPN IP in cloud provider metadata (if supported and required for autoscaling by the CSP, otherwise does nothing). @@ -43,10 +43,10 @@ type CloudControllerManager interface { ExtraArgs() []string // ConfigMaps returns a list of ConfigMaps to deploy together with the k8s cloud-controller-manager // Reference: https://kubernetes.io/docs/concepts/configuration/configmap/ . - ConfigMaps(instance cloudtypes.Instance) (resources.ConfigMaps, error) + ConfigMaps(instance metadata.InstanceMetadata) (resources.ConfigMaps, error) // Secrets returns a list of secrets to deploy together with the k8s cloud-controller-manager. // Reference: https://kubernetes.io/docs/concepts/configuration/secret/ . - Secrets(ctx context.Context, instance cloudtypes.Instance, cloudServiceAccountURI string) (resources.Secrets, error) + Secrets(ctx context.Context, providerID, cloudServiceAccountURI string) (resources.Secrets, error) // Volumes returns a list of volumes to deploy together with the k8s cloud-controller-manager. // Reference: https://kubernetes.io/docs/concepts/storage/volumes/ . Volumes() []k8s.Volume @@ -75,7 +75,7 @@ type ClusterAutoscaler interface { // Name returns the cloud-provider name as used by k8s cluster-autoscaler. Name() string // Secrets returns a list of secrets to deploy together with the k8s cluster-autoscaler. - Secrets(instance cloudtypes.Instance, cloudServiceAccountURI string) (resources.Secrets, error) + Secrets(providerID, cloudServiceAccountURI string) (resources.Secrets, error) // Volumes returns a list of volumes to deploy together with the k8s cluster-autoscaler. Volumes() []k8s.Volume // VolumeMounts returns a list of volume mounts to deploy together with the k8s cluster-autoscaler. @@ -94,16 +94,16 @@ type stubProviderMetadata struct { GetSubnetworkCIDRResp string ListErr error - ListResp []cloudtypes.Instance + ListResp []metadata.InstanceMetadata SignalRoleErr error SetVPNIPErr error SelfErr error - SelfResp cloudtypes.Instance + SelfResp metadata.InstanceMetadata GetInstanceErr error - GetInstanceResp cloudtypes.Instance + GetInstanceResp metadata.InstanceMetadata SupportedResp bool SupportsLoadBalancerResp bool @@ -117,15 +117,15 @@ func (m *stubProviderMetadata) GetSubnetworkCIDR(ctx context.Context) (string, e return m.GetSubnetworkCIDRResp, m.GetSubnetworkCIDRErr } -func (m *stubProviderMetadata) List(ctx context.Context) ([]cloudtypes.Instance, error) { +func (m *stubProviderMetadata) List(ctx context.Context) ([]metadata.InstanceMetadata, error) { return m.ListResp, m.ListErr } -func (m *stubProviderMetadata) Self(ctx context.Context) (cloudtypes.Instance, error) { +func (m *stubProviderMetadata) Self(ctx context.Context) (metadata.InstanceMetadata, error) { return m.SelfResp, m.SelfErr } -func (m *stubProviderMetadata) GetInstance(ctx context.Context, providerID string) (cloudtypes.Instance, error) { +func (m *stubProviderMetadata) GetInstance(ctx context.Context, providerID string) (metadata.InstanceMetadata, error) { return m.GetInstanceResp, m.GetInstanceErr } @@ -165,11 +165,11 @@ func (m *stubCloudControllerManager) ExtraArgs() []string { return []string{} } -func (m *stubCloudControllerManager) ConfigMaps(instance cloudtypes.Instance) (resources.ConfigMaps, error) { +func (m *stubCloudControllerManager) ConfigMaps(instance metadata.InstanceMetadata) (resources.ConfigMaps, error) { return []*k8s.ConfigMap{}, nil } -func (m *stubCloudControllerManager) Secrets(ctx context.Context, instance cloudtypes.Instance, cloudServiceAccountURI string) (resources.Secrets, error) { +func (m *stubCloudControllerManager) Secrets(ctx context.Context, instance, cloudServiceAccountURI string) (resources.Secrets, error) { return []*k8s.Secret{}, nil } @@ -222,7 +222,7 @@ func (a *stubClusterAutoscaler) Name() string { } // Secrets returns a list of secrets to deploy together with the k8s cluster-autoscaler. -func (a *stubClusterAutoscaler) Secrets(instance cloudtypes.Instance, cloudServiceAccountURI string) (resources.Secrets, error) { +func (a *stubClusterAutoscaler) Secrets(instance, cloudServiceAccountURI string) (resources.Secrets, error) { return resources.Secrets{}, nil } diff --git a/coordinator/kubernetes/k8sapi/install.go b/coordinator/internal/kubernetes/k8sapi/install.go similarity index 100% rename from coordinator/kubernetes/k8sapi/install.go rename to coordinator/internal/kubernetes/k8sapi/install.go diff --git a/coordinator/kubernetes/k8sapi/install_test.go b/coordinator/internal/kubernetes/k8sapi/install_test.go similarity index 100% rename from coordinator/kubernetes/k8sapi/install_test.go rename to coordinator/internal/kubernetes/k8sapi/install_test.go diff --git a/coordinator/kubernetes/k8sapi/joinargs.go b/coordinator/internal/kubernetes/k8sapi/joinargs.go similarity index 100% rename from coordinator/kubernetes/k8sapi/joinargs.go rename to coordinator/internal/kubernetes/k8sapi/joinargs.go diff --git a/coordinator/kubernetes/k8sapi/joinargs_test.go b/coordinator/internal/kubernetes/k8sapi/joinargs_test.go similarity index 100% rename from coordinator/kubernetes/k8sapi/joinargs_test.go rename to coordinator/internal/kubernetes/k8sapi/joinargs_test.go diff --git a/coordinator/kubernetes/k8sapi/kubeadm_config.go b/coordinator/internal/kubernetes/k8sapi/kubeadm_config.go similarity index 99% rename from coordinator/kubernetes/k8sapi/kubeadm_config.go rename to coordinator/internal/kubernetes/k8sapi/kubeadm_config.go index f840bc62c..e4f1b0e1d 100644 --- a/coordinator/kubernetes/k8sapi/kubeadm_config.go +++ b/coordinator/internal/kubernetes/k8sapi/kubeadm_config.go @@ -3,7 +3,7 @@ package k8sapi import ( "path/filepath" - "github.com/edgelesssys/constellation/coordinator/kubernetes/k8sapi/resources" + "github.com/edgelesssys/constellation/coordinator/internal/kubernetes/k8sapi/resources" "github.com/edgelesssys/constellation/internal/constants" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/coordinator/kubernetes/k8sapi/kubeadm_config_test.go b/coordinator/internal/kubernetes/k8sapi/kubeadm_config_test.go similarity index 100% rename from coordinator/kubernetes/k8sapi/kubeadm_config_test.go rename to coordinator/internal/kubernetes/k8sapi/kubeadm_config_test.go diff --git a/coordinator/kubernetes/k8sapi/kubectl/client/client.go b/coordinator/internal/kubernetes/k8sapi/kubectl/client/client.go similarity index 96% rename from coordinator/kubernetes/k8sapi/kubectl/client/client.go rename to coordinator/internal/kubernetes/k8sapi/kubectl/client/client.go index 4c3fa4d1c..b981e08d6 100644 --- a/coordinator/kubernetes/k8sapi/kubectl/client/client.go +++ b/coordinator/internal/kubernetes/k8sapi/kubectl/client/client.go @@ -4,7 +4,7 @@ import ( "bytes" "fmt" - "github.com/edgelesssys/constellation/coordinator/kubernetes/k8sapi/resources" + "github.com/edgelesssys/constellation/coordinator/internal/kubernetes/k8sapi/resources" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime" diff --git a/coordinator/kubernetes/k8sapi/kubectl/client/client_test.go b/coordinator/internal/kubernetes/k8sapi/kubectl/client/client_test.go similarity index 98% rename from coordinator/kubernetes/k8sapi/kubectl/client/client_test.go rename to coordinator/internal/kubernetes/k8sapi/kubectl/client/client_test.go index 9cc871481..6ddf74bf7 100644 --- a/coordinator/kubernetes/k8sapi/kubectl/client/client_test.go +++ b/coordinator/internal/kubernetes/k8sapi/kubectl/client/client_test.go @@ -7,7 +7,7 @@ import ( "net/http" "testing" - "github.com/edgelesssys/constellation/coordinator/kubernetes/k8sapi/resources" + "github.com/edgelesssys/constellation/coordinator/internal/kubernetes/k8sapi/resources" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "go.uber.org/goleak" diff --git a/coordinator/kubernetes/k8sapi/kubectl/client/restclient.go b/coordinator/internal/kubernetes/k8sapi/kubectl/client/restclient.go similarity index 100% rename from coordinator/kubernetes/k8sapi/kubectl/client/restclient.go rename to coordinator/internal/kubernetes/k8sapi/kubectl/client/restclient.go diff --git a/coordinator/kubernetes/k8sapi/kubectl/client/restclient_test.go b/coordinator/internal/kubernetes/k8sapi/kubectl/client/restclient_test.go similarity index 100% rename from coordinator/kubernetes/k8sapi/kubectl/client/restclient_test.go rename to coordinator/internal/kubernetes/k8sapi/kubectl/client/restclient_test.go diff --git a/coordinator/kubernetes/k8sapi/kubectl/generator.go b/coordinator/internal/kubernetes/k8sapi/kubectl/generator.go similarity index 72% rename from coordinator/kubernetes/k8sapi/kubectl/generator.go rename to coordinator/internal/kubernetes/k8sapi/kubectl/generator.go index 6efd5d7e0..c42d65e00 100644 --- a/coordinator/kubernetes/k8sapi/kubectl/generator.go +++ b/coordinator/internal/kubernetes/k8sapi/kubectl/generator.go @@ -1,6 +1,6 @@ package kubectl -import "github.com/edgelesssys/constellation/coordinator/kubernetes/k8sapi/kubectl/client" +import "github.com/edgelesssys/constellation/coordinator/internal/kubernetes/k8sapi/kubectl/client" // generator implements clientGenerator interface. type generator struct{} diff --git a/coordinator/kubernetes/k8sapi/kubectl/kubectl.go b/coordinator/internal/kubernetes/k8sapi/kubectl/kubectl.go similarity index 95% rename from coordinator/kubernetes/k8sapi/kubectl/kubectl.go rename to coordinator/internal/kubernetes/k8sapi/kubectl/kubectl.go index c48b6d6db..8d967b529 100644 --- a/coordinator/kubernetes/k8sapi/kubectl/kubectl.go +++ b/coordinator/internal/kubernetes/k8sapi/kubectl/kubectl.go @@ -4,7 +4,7 @@ import ( "errors" "fmt" - "github.com/edgelesssys/constellation/coordinator/kubernetes/k8sapi/resources" + "github.com/edgelesssys/constellation/coordinator/internal/kubernetes/k8sapi/resources" "k8s.io/cli-runtime/pkg/resource" ) diff --git a/coordinator/kubernetes/k8sapi/kubectl/kubectl_test.go b/coordinator/internal/kubernetes/k8sapi/kubectl/kubectl_test.go similarity index 96% rename from coordinator/kubernetes/k8sapi/kubectl/kubectl_test.go rename to coordinator/internal/kubernetes/k8sapi/kubectl/kubectl_test.go index 14095bb64..03018bb75 100644 --- a/coordinator/kubernetes/k8sapi/kubectl/kubectl_test.go +++ b/coordinator/internal/kubernetes/k8sapi/kubectl/kubectl_test.go @@ -4,7 +4,7 @@ import ( "errors" "testing" - "github.com/edgelesssys/constellation/coordinator/kubernetes/k8sapi/resources" + "github.com/edgelesssys/constellation/coordinator/internal/kubernetes/k8sapi/resources" "github.com/stretchr/testify/assert" "go.uber.org/goleak" "k8s.io/cli-runtime/pkg/resource" diff --git a/coordinator/kubernetes/k8sapi/resources/access_manager.go b/coordinator/internal/kubernetes/k8sapi/resources/access_manager.go similarity index 100% rename from coordinator/kubernetes/k8sapi/resources/access_manager.go rename to coordinator/internal/kubernetes/k8sapi/resources/access_manager.go diff --git a/coordinator/kubernetes/k8sapi/resources/access_manager_test.go b/coordinator/internal/kubernetes/k8sapi/resources/access_manager_test.go similarity index 100% rename from coordinator/kubernetes/k8sapi/resources/access_manager_test.go rename to coordinator/internal/kubernetes/k8sapi/resources/access_manager_test.go diff --git a/coordinator/kubernetes/k8sapi/resources/activation.go b/coordinator/internal/kubernetes/k8sapi/resources/activation.go similarity index 100% rename from coordinator/kubernetes/k8sapi/resources/activation.go rename to coordinator/internal/kubernetes/k8sapi/resources/activation.go diff --git a/coordinator/kubernetes/k8sapi/resources/activation_test.go b/coordinator/internal/kubernetes/k8sapi/resources/activation_test.go similarity index 100% rename from coordinator/kubernetes/k8sapi/resources/activation_test.go rename to coordinator/internal/kubernetes/k8sapi/resources/activation_test.go diff --git a/coordinator/kubernetes/k8sapi/resources/auditpolicy.go b/coordinator/internal/kubernetes/k8sapi/resources/auditpolicy.go similarity index 100% rename from coordinator/kubernetes/k8sapi/resources/auditpolicy.go rename to coordinator/internal/kubernetes/k8sapi/resources/auditpolicy.go diff --git a/coordinator/kubernetes/k8sapi/resources/auditpolicy_test.go b/coordinator/internal/kubernetes/k8sapi/resources/auditpolicy_test.go similarity index 100% rename from coordinator/kubernetes/k8sapi/resources/auditpolicy_test.go rename to coordinator/internal/kubernetes/k8sapi/resources/auditpolicy_test.go diff --git a/coordinator/kubernetes/k8sapi/resources/cloud_controller_manager.go b/coordinator/internal/kubernetes/k8sapi/resources/cloud_controller_manager.go similarity index 100% rename from coordinator/kubernetes/k8sapi/resources/cloud_controller_manager.go rename to coordinator/internal/kubernetes/k8sapi/resources/cloud_controller_manager.go diff --git a/coordinator/kubernetes/k8sapi/resources/cloud_controller_manager_test.go b/coordinator/internal/kubernetes/k8sapi/resources/cloud_controller_manager_test.go similarity index 100% rename from coordinator/kubernetes/k8sapi/resources/cloud_controller_manager_test.go rename to coordinator/internal/kubernetes/k8sapi/resources/cloud_controller_manager_test.go diff --git a/coordinator/kubernetes/k8sapi/resources/cloudnodemanager.go b/coordinator/internal/kubernetes/k8sapi/resources/cloudnodemanager.go similarity index 100% rename from coordinator/kubernetes/k8sapi/resources/cloudnodemanager.go rename to coordinator/internal/kubernetes/k8sapi/resources/cloudnodemanager.go diff --git a/coordinator/kubernetes/k8sapi/resources/cloudnodemanager_test.go b/coordinator/internal/kubernetes/k8sapi/resources/cloudnodemanager_test.go similarity index 100% rename from coordinator/kubernetes/k8sapi/resources/cloudnodemanager_test.go rename to coordinator/internal/kubernetes/k8sapi/resources/cloudnodemanager_test.go diff --git a/coordinator/kubernetes/k8sapi/resources/cluster_autoscaler.go b/coordinator/internal/kubernetes/k8sapi/resources/cluster_autoscaler.go similarity index 100% rename from coordinator/kubernetes/k8sapi/resources/cluster_autoscaler.go rename to coordinator/internal/kubernetes/k8sapi/resources/cluster_autoscaler.go diff --git a/coordinator/kubernetes/k8sapi/resources/cluster_autoscaler_test.go b/coordinator/internal/kubernetes/k8sapi/resources/cluster_autoscaler_test.go similarity index 100% rename from coordinator/kubernetes/k8sapi/resources/cluster_autoscaler_test.go rename to coordinator/internal/kubernetes/k8sapi/resources/cluster_autoscaler_test.go diff --git a/coordinator/kubernetes/k8sapi/resources/configmaps.go b/coordinator/internal/kubernetes/k8sapi/resources/configmaps.go similarity index 100% rename from coordinator/kubernetes/k8sapi/resources/configmaps.go rename to coordinator/internal/kubernetes/k8sapi/resources/configmaps.go diff --git a/coordinator/kubernetes/k8sapi/resources/configmaps_test.go b/coordinator/internal/kubernetes/k8sapi/resources/configmaps_test.go similarity index 100% rename from coordinator/kubernetes/k8sapi/resources/configmaps_test.go rename to coordinator/internal/kubernetes/k8sapi/resources/configmaps_test.go diff --git a/coordinator/kubernetes/k8sapi/resources/image_pull_secret.go b/coordinator/internal/kubernetes/k8sapi/resources/image_pull_secret.go similarity index 100% rename from coordinator/kubernetes/k8sapi/resources/image_pull_secret.go rename to coordinator/internal/kubernetes/k8sapi/resources/image_pull_secret.go diff --git a/coordinator/kubernetes/k8sapi/resources/image_pull_secret_test.go b/coordinator/internal/kubernetes/k8sapi/resources/image_pull_secret_test.go similarity index 100% rename from coordinator/kubernetes/k8sapi/resources/image_pull_secret_test.go rename to coordinator/internal/kubernetes/k8sapi/resources/image_pull_secret_test.go diff --git a/coordinator/kubernetes/k8sapi/resources/kms.go b/coordinator/internal/kubernetes/k8sapi/resources/kms.go similarity index 100% rename from coordinator/kubernetes/k8sapi/resources/kms.go rename to coordinator/internal/kubernetes/k8sapi/resources/kms.go diff --git a/coordinator/kubernetes/k8sapi/resources/kms_test.go b/coordinator/internal/kubernetes/k8sapi/resources/kms_test.go similarity index 100% rename from coordinator/kubernetes/k8sapi/resources/kms_test.go rename to coordinator/internal/kubernetes/k8sapi/resources/kms_test.go diff --git a/coordinator/kubernetes/k8sapi/resources/marshal.go b/coordinator/internal/kubernetes/k8sapi/resources/marshal.go similarity index 100% rename from coordinator/kubernetes/k8sapi/resources/marshal.go rename to coordinator/internal/kubernetes/k8sapi/resources/marshal.go diff --git a/coordinator/kubernetes/k8sapi/resources/marshal_test.go b/coordinator/internal/kubernetes/k8sapi/resources/marshal_test.go similarity index 100% rename from coordinator/kubernetes/k8sapi/resources/marshal_test.go rename to coordinator/internal/kubernetes/k8sapi/resources/marshal_test.go diff --git a/coordinator/kubernetes/k8sapi/resources/secrets.go b/coordinator/internal/kubernetes/k8sapi/resources/secrets.go similarity index 100% rename from coordinator/kubernetes/k8sapi/resources/secrets.go rename to coordinator/internal/kubernetes/k8sapi/resources/secrets.go diff --git a/coordinator/kubernetes/k8sapi/resources/secrets_test.go b/coordinator/internal/kubernetes/k8sapi/resources/secrets_test.go similarity index 100% rename from coordinator/kubernetes/k8sapi/resources/secrets_test.go rename to coordinator/internal/kubernetes/k8sapi/resources/secrets_test.go diff --git a/coordinator/kubernetes/k8sapi/systemd.go b/coordinator/internal/kubernetes/k8sapi/systemd.go similarity index 100% rename from coordinator/kubernetes/k8sapi/systemd.go rename to coordinator/internal/kubernetes/k8sapi/systemd.go diff --git a/coordinator/kubernetes/k8sapi/util.go b/coordinator/internal/kubernetes/k8sapi/util.go similarity index 99% rename from coordinator/kubernetes/k8sapi/util.go rename to coordinator/internal/kubernetes/k8sapi/util.go index 3ca2b6033..9ee483a01 100644 --- a/coordinator/kubernetes/k8sapi/util.go +++ b/coordinator/internal/kubernetes/k8sapi/util.go @@ -11,7 +11,7 @@ import ( "strings" "time" - "github.com/edgelesssys/constellation/coordinator/kubernetes/k8sapi/resources" + "github.com/edgelesssys/constellation/coordinator/internal/kubernetes/k8sapi/resources" kubeadm "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta3" ) diff --git a/coordinator/kubernetes/k8sapi/versions.go b/coordinator/internal/kubernetes/k8sapi/versions.go similarity index 100% rename from coordinator/kubernetes/k8sapi/versions.go rename to coordinator/internal/kubernetes/k8sapi/versions.go diff --git a/coordinator/kubernetes/k8sutil.go b/coordinator/internal/kubernetes/k8sutil.go similarity index 89% rename from coordinator/kubernetes/k8sutil.go rename to coordinator/internal/kubernetes/k8sutil.go index 74e6803c6..71b139d17 100644 --- a/coordinator/kubernetes/k8sutil.go +++ b/coordinator/internal/kubernetes/k8sutil.go @@ -4,8 +4,8 @@ import ( "context" "time" - "github.com/edgelesssys/constellation/coordinator/kubernetes/k8sapi" - "github.com/edgelesssys/constellation/coordinator/kubernetes/k8sapi/resources" + "github.com/edgelesssys/constellation/coordinator/internal/kubernetes/k8sapi" + "github.com/edgelesssys/constellation/coordinator/internal/kubernetes/k8sapi/resources" kubeadm "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta3" ) diff --git a/coordinator/kubernetes/kubeconfig.go b/coordinator/internal/kubernetes/kubeconfig.go similarity index 100% rename from coordinator/kubernetes/kubeconfig.go rename to coordinator/internal/kubernetes/kubeconfig.go diff --git a/coordinator/kubernetes/kubeconfig_test.go b/coordinator/internal/kubernetes/kubeconfig_test.go similarity index 100% rename from coordinator/kubernetes/kubeconfig_test.go rename to coordinator/internal/kubernetes/kubeconfig_test.go diff --git a/coordinator/kubernetes/kubernetes.go b/coordinator/internal/kubernetes/kubernetes.go similarity index 93% rename from coordinator/kubernetes/kubernetes.go rename to coordinator/internal/kubernetes/kubernetes.go index 7b52c5b11..a0c007dc6 100644 --- a/coordinator/kubernetes/kubernetes.go +++ b/coordinator/internal/kubernetes/kubernetes.go @@ -7,12 +7,12 @@ import ( "strings" "time" - "github.com/edgelesssys/constellation/coordinator/cloudprovider/cloudtypes" - "github.com/edgelesssys/constellation/coordinator/kubernetes/k8sapi" - "github.com/edgelesssys/constellation/coordinator/kubernetes/k8sapi/resources" + "github.com/edgelesssys/constellation/coordinator/internal/kubernetes/k8sapi" + "github.com/edgelesssys/constellation/coordinator/internal/kubernetes/k8sapi/resources" "github.com/edgelesssys/constellation/coordinator/role" "github.com/edgelesssys/constellation/coordinator/util" attestationtypes "github.com/edgelesssys/constellation/internal/attestation/types" + "github.com/edgelesssys/constellation/internal/cloud/metadata" "github.com/spf13/afero" kubeadm "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta3" ) @@ -40,6 +40,7 @@ type KubeWrapper struct { clusterAutoscaler ClusterAutoscaler providerMetadata ProviderMetadata initialMeasurementsJSON []byte + getIPAddr func() (string, error) } // New creates a new KubeWrapper with real values. @@ -57,6 +58,7 @@ func New(cloudProvider string, clusterUtil clusterUtil, configProvider configura clusterAutoscaler: clusterAutoscaler, providerMetadata: providerMetadata, initialMeasurementsJSON: initialMeasurementsJSON, + getIPAddr: util.GetIPAddr, } } @@ -78,13 +80,13 @@ func (k *KubeWrapper) InitCluster( return err } - ip, err := util.GetIPAddr() + ip, err := k.getIPAddr() if err != nil { return err } nodeName := ip var providerID string - var instance cloudtypes.Instance + var instance metadata.InstanceMetadata var publicIP string var nodePodCIDR string var subnetworkPodCIDR string @@ -192,18 +194,21 @@ func (k *KubeWrapper) InitCluster( } // JoinCluster joins existing Kubernetes cluster. -func (k *KubeWrapper) JoinCluster(ctx context.Context, args *kubeadm.BootstrapTokenDiscovery, nodeVPNIP, certKey string, peerRole role.Role) error { +func (k *KubeWrapper) JoinCluster(ctx context.Context, args *kubeadm.BootstrapTokenDiscovery, certKey string, peerRole role.Role) error { // TODO: k8s version should be user input - if err := k.clusterUtil.InstallComponents(context.TODO(), "1.23.6"); err != nil { + if err := k.clusterUtil.InstallComponents(ctx, "1.23.6"); err != nil { return err } // Step 1: retrieve cloud metadata for Kubernetes configuration + nodeInternalIP, err := k.getIPAddr() + if err != nil { + return err + } + nodeName := nodeInternalIP var providerID string - nodeName := nodeVPNIP - nodeInternalIP := nodeVPNIP if k.providerMetadata.Supported() { - instance, err := k.providerMetadata.Self(context.TODO()) + instance, err := k.providerMetadata.Self(ctx) if err != nil { return fmt.Errorf("retrieving own instance metadata failed: %w", err) } @@ -274,7 +279,7 @@ func (k *KubeWrapper) setupActivationService(csp string, measurementsJSON []byte return k.clusterUtil.SetupActivationService(k.client, activationConfiguration) } -func (k *KubeWrapper) setupCCM(ctx context.Context, subnetworkPodCIDR, cloudServiceAccountURI string, instance cloudtypes.Instance) error { +func (k *KubeWrapper) setupCCM(ctx context.Context, subnetworkPodCIDR, cloudServiceAccountURI string, instance metadata.InstanceMetadata) error { if !k.cloudControllerManager.Supported() { return nil } @@ -312,7 +317,7 @@ func (k *KubeWrapper) setupCloudNodeManager() error { return nil } -func (k *KubeWrapper) setupClusterAutoscaler(instance cloudtypes.Instance, cloudServiceAccountURI string, autoscalingNodeGroups []string) error { +func (k *KubeWrapper) setupClusterAutoscaler(instance metadata.InstanceMetadata, cloudServiceAccountURI string, autoscalingNodeGroups []string) error { if !k.clusterAutoscaler.Supported() { return nil } diff --git a/coordinator/kubernetes/kubernetes_test.go b/coordinator/internal/kubernetes/kubernetes_test.go similarity index 94% rename from coordinator/kubernetes/kubernetes_test.go rename to coordinator/internal/kubernetes/kubernetes_test.go index b72c665a6..8bd1be34b 100644 --- a/coordinator/kubernetes/kubernetes_test.go +++ b/coordinator/internal/kubernetes/kubernetes_test.go @@ -7,11 +7,11 @@ import ( "testing" "time" - "github.com/edgelesssys/constellation/coordinator/cloudprovider/cloudtypes" - "github.com/edgelesssys/constellation/coordinator/kubernetes/k8sapi" - "github.com/edgelesssys/constellation/coordinator/kubernetes/k8sapi/resources" + "github.com/edgelesssys/constellation/coordinator/internal/kubernetes/k8sapi" + "github.com/edgelesssys/constellation/coordinator/internal/kubernetes/k8sapi/resources" "github.com/edgelesssys/constellation/coordinator/role" attestationtypes "github.com/edgelesssys/constellation/internal/attestation/types" + "github.com/edgelesssys/constellation/internal/cloud/metadata" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "go.uber.org/goleak" @@ -24,7 +24,6 @@ func TestMain(m *testing.M) { func TestInitCluster(t *testing.T) { someErr := errors.New("failed") - coordinatorVPNIP := "192.0.2.0" serviceAccountUri := "some-service-account-uri" masterSecret := []byte("some-master-secret") autoscalingNodeGroups := []string{"0,10,autoscaling_group_0"} @@ -64,7 +63,7 @@ func TestInitCluster(t *testing.T) { "node-ip": "", "provider-id": "", }, - Name: coordinatorVPNIP, + Name: privateIP, }, }, ClusterConfiguration: kubeadm.ClusterConfiguration{}, @@ -77,7 +76,7 @@ func TestInitCluster(t *testing.T) { }, providerMetadata: &stubProviderMetadata{ SupportedResp: true, - SelfResp: cloudtypes.Instance{ + SelfResp: metadata.InstanceMetadata{ Name: nodeName, ProviderID: providerID, PrivateIPs: []string{privateIP}, @@ -267,6 +266,7 @@ func TestInitCluster(t *testing.T) { configProvider: &stubConfigProvider{InitConfig: k8sapi.KubeadmInitYAML{}}, client: &tc.kubeCTL, kubeconfigReader: tc.kubeconfigReader, + getIPAddr: func() (string, error) { return privateIP, nil }, } err := kube.InitCluster(context.Background(), autoscalingNodeGroups, serviceAccountUri, k8sVersion, attestationtypes.ID{}, KMSConfig{MasterSecret: masterSecret}, nil) @@ -292,7 +292,7 @@ func TestJoinCluster(t *testing.T) { CACertHashes: []string{"sha256:a60ebe9b0879090edd83b40a4df4bebb20506bac1e51d518ff8f4505a721930f"}, } - nodeVPNIP := "192.0.2.0" + privateIP := "192.0.2.1" certKey := "cert-key" testCases := map[string]struct { @@ -313,8 +313,8 @@ func TestJoinCluster(t *testing.T) { BootstrapToken: joinCommand, }, NodeRegistration: kubeadm.NodeRegistrationOptions{ - Name: nodeVPNIP, - KubeletExtraArgs: map[string]string{"node-ip": "192.0.2.0"}, + Name: privateIP, + KubeletExtraArgs: map[string]string{"node-ip": privateIP}, }, }, }, @@ -322,7 +322,7 @@ func TestJoinCluster(t *testing.T) { clusterUtil: stubClusterUtil{}, providerMetadata: &stubProviderMetadata{ SupportedResp: true, - SelfResp: cloudtypes.Instance{ + SelfResp: metadata.InstanceMetadata{ ProviderID: "provider-id", Name: "metadata-name", PrivateIPs: []string{"192.0.2.1"}, @@ -344,7 +344,7 @@ func TestJoinCluster(t *testing.T) { clusterUtil: stubClusterUtil{}, providerMetadata: &stubProviderMetadata{ SupportedResp: true, - SelfResp: cloudtypes.Instance{ + SelfResp: metadata.InstanceMetadata{ ProviderID: "provider-id", Name: "metadata-name", PrivateIPs: []string{"192.0.2.1"}, @@ -368,7 +368,7 @@ func TestJoinCluster(t *testing.T) { clusterUtil: stubClusterUtil{}, providerMetadata: &stubProviderMetadata{ SupportedResp: true, - SelfResp: cloudtypes.Instance{ + SelfResp: metadata.InstanceMetadata{ ProviderID: "provider-id", Name: "metadata-name", PrivateIPs: []string{"192.0.2.1"}, @@ -410,23 +410,6 @@ func TestJoinCluster(t *testing.T) { role: role.Node, wantErr: true, }, - "kubeadm join worker works fails when setting the metadata for the cloud controller manager": { - clusterUtil: stubClusterUtil{}, - providerMetadata: &stubProviderMetadata{ - SupportedResp: true, - SelfResp: cloudtypes.Instance{ - ProviderID: "provider-id", - Name: "metadata-name", - PrivateIPs: []string{"192.0.2.1"}, - }, - SetVPNIPErr: someErr, - }, - CloudControllerManager: &stubCloudControllerManager{ - SupportedResp: true, - }, - role: role.Node, - wantErr: true, - }, } for name, tc := range testCases { @@ -439,9 +422,10 @@ func TestJoinCluster(t *testing.T) { providerMetadata: tc.providerMetadata, cloudControllerManager: tc.CloudControllerManager, configProvider: &stubConfigProvider{}, + getIPAddr: func() (string, error) { return privateIP, nil }, } - err := kube.JoinCluster(context.Background(), joinCommand, nodeVPNIP, certKey, tc.role) + err := kube.JoinCluster(context.Background(), joinCommand, certKey, tc.role) if tc.wantErr { assert.Error(err) return diff --git a/docs/upgrade-kubernetes.md b/docs/upgrade-kubernetes.md index 48c6fdc45..3262a6991 100644 --- a/docs/upgrade-kubernetes.md +++ b/docs/upgrade-kubernetes.md @@ -56,7 +56,7 @@ const ( ## Upgrading Kubernetes resources During the cluster initialization, multiple Kubernetes resources are deployed. Some of these should be upgraded with Kubernetes. -Look at [the resources folder](/coordinator/kubernetes/k8sapi/resources) and decide what needs to be upgraded. Cloud provider specific images are defined in [`github.com/edgelesssys/constellation/coordinator/cloudprovider`](/coordinator/cloudprovider/images.go). You can check available version tags for container images using [the container registry tags API](https://docs.docker.com/registry/spec/api/#listing-image-tags): +Look at [the resources folder](/coordinator/internal/kubernetes/k8sapi/resources) and decide what needs to be upgraded. Cloud provider specific images are defined in [`github.com/edgelesssys/constellation/coordinator/cloudprovider`](/coordinator/cloudprovider/images.go). You can check available version tags for container images using [the container registry tags API](https://docs.docker.com/registry/spec/api/#listing-image-tags): ``` curl -q https://k8s.gcr.io/v2/autoscaling/cluster-autoscaler/tags/list | jq .tags