mirror of
https://github.com/edgelesssys/constellation.git
synced 2024-10-01 01:36:09 -04:00
Move kubernetes package into internal
This commit is contained in:
parent
09e86e6c5d
commit
fc35084379
@ -1,7 +1,7 @@
|
|||||||
package azure
|
package azure
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"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/azureshared"
|
||||||
k8s "k8s.io/api/core/v1"
|
k8s "k8s.io/api/core/v1"
|
||||||
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
@ -3,7 +3,7 @@ package azure
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"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/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
k8s "k8s.io/api/core/v1"
|
k8s "k8s.io/api/core/v1"
|
||||||
|
@ -5,7 +5,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/edgelesssys/constellation/coordinator/cloudprovider"
|
"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/azureshared"
|
||||||
"github.com/edgelesssys/constellation/internal/cloud/metadata"
|
"github.com/edgelesssys/constellation/internal/cloud/metadata"
|
||||||
k8s "k8s.io/api/core/v1"
|
k8s "k8s.io/api/core/v1"
|
||||||
|
@ -5,7 +5,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"testing"
|
"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/cloud/metadata"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package gcp
|
package gcp
|
||||||
|
|
||||||
import (
|
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"
|
"github.com/edgelesssys/constellation/internal/cloud/metadata"
|
||||||
k8s "k8s.io/api/core/v1"
|
k8s "k8s.io/api/core/v1"
|
||||||
)
|
)
|
||||||
|
@ -7,7 +7,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/edgelesssys/constellation/coordinator/cloudprovider"
|
"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/cloud/metadata"
|
||||||
"github.com/edgelesssys/constellation/internal/gcpshared"
|
"github.com/edgelesssys/constellation/internal/gcpshared"
|
||||||
k8s "k8s.io/api/core/v1"
|
k8s "k8s.io/api/core/v1"
|
||||||
|
@ -5,7 +5,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"testing"
|
"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/cloud/metadata"
|
||||||
"github.com/edgelesssys/constellation/internal/gcpshared"
|
"github.com/edgelesssys/constellation/internal/gcpshared"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package qemu
|
package qemu
|
||||||
|
|
||||||
import (
|
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"
|
"github.com/edgelesssys/constellation/internal/cloud/metadata"
|
||||||
k8s "k8s.io/api/core/v1"
|
k8s "k8s.io/api/core/v1"
|
||||||
)
|
)
|
||||||
|
@ -3,7 +3,7 @@ package qemu
|
|||||||
import (
|
import (
|
||||||
"context"
|
"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"
|
"github.com/edgelesssys/constellation/internal/cloud/metadata"
|
||||||
k8s "k8s.io/api/core/v1"
|
k8s "k8s.io/api/core/v1"
|
||||||
)
|
)
|
||||||
|
@ -14,9 +14,9 @@ import (
|
|||||||
qemucloud "github.com/edgelesssys/constellation/coordinator/cloudprovider/qemu"
|
qemucloud "github.com/edgelesssys/constellation/coordinator/cloudprovider/qemu"
|
||||||
"github.com/edgelesssys/constellation/coordinator/config"
|
"github.com/edgelesssys/constellation/coordinator/config"
|
||||||
"github.com/edgelesssys/constellation/coordinator/core"
|
"github.com/edgelesssys/constellation/coordinator/core"
|
||||||
"github.com/edgelesssys/constellation/coordinator/kubernetes"
|
"github.com/edgelesssys/constellation/coordinator/internal/kubernetes"
|
||||||
"github.com/edgelesssys/constellation/coordinator/kubernetes/k8sapi"
|
"github.com/edgelesssys/constellation/coordinator/internal/kubernetes/k8sapi"
|
||||||
"github.com/edgelesssys/constellation/coordinator/kubernetes/k8sapi/kubectl"
|
"github.com/edgelesssys/constellation/coordinator/internal/kubernetes/k8sapi/kubectl"
|
||||||
"github.com/edgelesssys/constellation/coordinator/logging"
|
"github.com/edgelesssys/constellation/coordinator/logging"
|
||||||
"github.com/edgelesssys/constellation/internal/atls"
|
"github.com/edgelesssys/constellation/internal/atls"
|
||||||
"github.com/edgelesssys/constellation/internal/attestation/azure"
|
"github.com/edgelesssys/constellation/internal/attestation/azure"
|
||||||
|
@ -10,7 +10,7 @@ import (
|
|||||||
"github.com/edgelesssys/constellation/coordinator/config"
|
"github.com/edgelesssys/constellation/coordinator/config"
|
||||||
"github.com/edgelesssys/constellation/coordinator/diskencryption"
|
"github.com/edgelesssys/constellation/coordinator/diskencryption"
|
||||||
"github.com/edgelesssys/constellation/coordinator/initproto"
|
"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/nodestate"
|
||||||
"github.com/edgelesssys/constellation/coordinator/role"
|
"github.com/edgelesssys/constellation/coordinator/role"
|
||||||
"github.com/edgelesssys/constellation/coordinator/util"
|
"github.com/edgelesssys/constellation/coordinator/util"
|
||||||
|
@ -3,18 +3,18 @@ package kubernetes
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/edgelesssys/constellation/coordinator/cloudprovider/cloudtypes"
|
"github.com/edgelesssys/constellation/coordinator/internal/kubernetes/k8sapi/resources"
|
||||||
"github.com/edgelesssys/constellation/coordinator/kubernetes/k8sapi/resources"
|
|
||||||
"github.com/edgelesssys/constellation/coordinator/role"
|
"github.com/edgelesssys/constellation/coordinator/role"
|
||||||
|
"github.com/edgelesssys/constellation/internal/cloud/metadata"
|
||||||
k8s "k8s.io/api/core/v1"
|
k8s "k8s.io/api/core/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ProviderMetadata implementers read/write cloud provider metadata.
|
// ProviderMetadata implementers read/write cloud provider metadata.
|
||||||
type ProviderMetadata interface {
|
type ProviderMetadata interface {
|
||||||
// List retrieves all instances belonging to the current Constellation.
|
// 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 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 retrieves the subnetwork CIDR for the current instance.
|
||||||
GetSubnetworkCIDR(ctx context.Context) (string, error)
|
GetSubnetworkCIDR(ctx context.Context) (string, error)
|
||||||
// SupportsLoadBalancer returns true if the cloud provider supports load balancers.
|
// SupportsLoadBalancer returns true if the cloud provider supports load balancers.
|
||||||
@ -22,7 +22,7 @@ type ProviderMetadata interface {
|
|||||||
// GetLoadBalancerIP retrieves the load balancer IP.
|
// GetLoadBalancerIP retrieves the load balancer IP.
|
||||||
GetLoadBalancerIP(ctx context.Context) (string, error)
|
GetLoadBalancerIP(ctx context.Context) (string, error)
|
||||||
// GetInstance retrieves an instance using its providerID.
|
// 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 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
|
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).
|
// 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
|
ExtraArgs() []string
|
||||||
// ConfigMaps returns a list of ConfigMaps to deploy together with the k8s cloud-controller-manager
|
// ConfigMaps returns a list of ConfigMaps to deploy together with the k8s cloud-controller-manager
|
||||||
// Reference: https://kubernetes.io/docs/concepts/configuration/configmap/ .
|
// 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.
|
// Secrets returns a list of secrets to deploy together with the k8s cloud-controller-manager.
|
||||||
// Reference: https://kubernetes.io/docs/concepts/configuration/secret/ .
|
// 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.
|
// Volumes returns a list of volumes to deploy together with the k8s cloud-controller-manager.
|
||||||
// Reference: https://kubernetes.io/docs/concepts/storage/volumes/ .
|
// Reference: https://kubernetes.io/docs/concepts/storage/volumes/ .
|
||||||
Volumes() []k8s.Volume
|
Volumes() []k8s.Volume
|
||||||
@ -75,7 +75,7 @@ type ClusterAutoscaler interface {
|
|||||||
// Name returns the cloud-provider name as used by k8s cluster-autoscaler.
|
// Name returns the cloud-provider name as used by k8s cluster-autoscaler.
|
||||||
Name() string
|
Name() string
|
||||||
// Secrets returns a list of secrets to deploy together with the k8s cluster-autoscaler.
|
// 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 returns a list of volumes to deploy together with the k8s cluster-autoscaler.
|
||||||
Volumes() []k8s.Volume
|
Volumes() []k8s.Volume
|
||||||
// VolumeMounts returns a list of volume mounts to deploy together with the k8s cluster-autoscaler.
|
// VolumeMounts returns a list of volume mounts to deploy together with the k8s cluster-autoscaler.
|
||||||
@ -94,16 +94,16 @@ type stubProviderMetadata struct {
|
|||||||
GetSubnetworkCIDRResp string
|
GetSubnetworkCIDRResp string
|
||||||
|
|
||||||
ListErr error
|
ListErr error
|
||||||
ListResp []cloudtypes.Instance
|
ListResp []metadata.InstanceMetadata
|
||||||
|
|
||||||
SignalRoleErr error
|
SignalRoleErr error
|
||||||
SetVPNIPErr error
|
SetVPNIPErr error
|
||||||
|
|
||||||
SelfErr error
|
SelfErr error
|
||||||
SelfResp cloudtypes.Instance
|
SelfResp metadata.InstanceMetadata
|
||||||
|
|
||||||
GetInstanceErr error
|
GetInstanceErr error
|
||||||
GetInstanceResp cloudtypes.Instance
|
GetInstanceResp metadata.InstanceMetadata
|
||||||
|
|
||||||
SupportedResp bool
|
SupportedResp bool
|
||||||
SupportsLoadBalancerResp bool
|
SupportsLoadBalancerResp bool
|
||||||
@ -117,15 +117,15 @@ func (m *stubProviderMetadata) GetSubnetworkCIDR(ctx context.Context) (string, e
|
|||||||
return m.GetSubnetworkCIDRResp, m.GetSubnetworkCIDRErr
|
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
|
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
|
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
|
return m.GetInstanceResp, m.GetInstanceErr
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,11 +165,11 @@ func (m *stubCloudControllerManager) ExtraArgs() []string {
|
|||||||
return []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
|
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
|
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.
|
// 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
|
return resources.Secrets{}, nil
|
||||||
}
|
}
|
||||||
|
|
@ -3,7 +3,7 @@ package k8sapi
|
|||||||
import (
|
import (
|
||||||
"path/filepath"
|
"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"
|
"github.com/edgelesssys/constellation/internal/constants"
|
||||||
corev1 "k8s.io/api/core/v1"
|
corev1 "k8s.io/api/core/v1"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
@ -4,7 +4,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"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"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
@ -7,7 +7,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"testing"
|
"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/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"go.uber.org/goleak"
|
"go.uber.org/goleak"
|
@ -1,6 +1,6 @@
|
|||||||
package kubectl
|
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.
|
// generator implements clientGenerator interface.
|
||||||
type generator struct{}
|
type generator struct{}
|
@ -4,7 +4,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/edgelesssys/constellation/coordinator/kubernetes/k8sapi/resources"
|
"github.com/edgelesssys/constellation/coordinator/internal/kubernetes/k8sapi/resources"
|
||||||
"k8s.io/cli-runtime/pkg/resource"
|
"k8s.io/cli-runtime/pkg/resource"
|
||||||
)
|
)
|
||||||
|
|
@ -4,7 +4,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"testing"
|
"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/assert"
|
||||||
"go.uber.org/goleak"
|
"go.uber.org/goleak"
|
||||||
"k8s.io/cli-runtime/pkg/resource"
|
"k8s.io/cli-runtime/pkg/resource"
|
@ -11,7 +11,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"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"
|
kubeadm "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta3"
|
||||||
)
|
)
|
||||||
|
|
@ -4,8 +4,8 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/edgelesssys/constellation/coordinator/kubernetes/k8sapi"
|
"github.com/edgelesssys/constellation/coordinator/internal/kubernetes/k8sapi"
|
||||||
"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"
|
kubeadm "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta3"
|
||||||
)
|
)
|
||||||
|
|
@ -7,12 +7,12 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/edgelesssys/constellation/coordinator/cloudprovider/cloudtypes"
|
"github.com/edgelesssys/constellation/coordinator/internal/kubernetes/k8sapi"
|
||||||
"github.com/edgelesssys/constellation/coordinator/kubernetes/k8sapi"
|
"github.com/edgelesssys/constellation/coordinator/internal/kubernetes/k8sapi/resources"
|
||||||
"github.com/edgelesssys/constellation/coordinator/kubernetes/k8sapi/resources"
|
|
||||||
"github.com/edgelesssys/constellation/coordinator/role"
|
"github.com/edgelesssys/constellation/coordinator/role"
|
||||||
"github.com/edgelesssys/constellation/coordinator/util"
|
"github.com/edgelesssys/constellation/coordinator/util"
|
||||||
attestationtypes "github.com/edgelesssys/constellation/internal/attestation/types"
|
attestationtypes "github.com/edgelesssys/constellation/internal/attestation/types"
|
||||||
|
"github.com/edgelesssys/constellation/internal/cloud/metadata"
|
||||||
"github.com/spf13/afero"
|
"github.com/spf13/afero"
|
||||||
kubeadm "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta3"
|
kubeadm "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta3"
|
||||||
)
|
)
|
||||||
@ -40,6 +40,7 @@ type KubeWrapper struct {
|
|||||||
clusterAutoscaler ClusterAutoscaler
|
clusterAutoscaler ClusterAutoscaler
|
||||||
providerMetadata ProviderMetadata
|
providerMetadata ProviderMetadata
|
||||||
initialMeasurementsJSON []byte
|
initialMeasurementsJSON []byte
|
||||||
|
getIPAddr func() (string, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// New creates a new KubeWrapper with real values.
|
// New creates a new KubeWrapper with real values.
|
||||||
@ -57,6 +58,7 @@ func New(cloudProvider string, clusterUtil clusterUtil, configProvider configura
|
|||||||
clusterAutoscaler: clusterAutoscaler,
|
clusterAutoscaler: clusterAutoscaler,
|
||||||
providerMetadata: providerMetadata,
|
providerMetadata: providerMetadata,
|
||||||
initialMeasurementsJSON: initialMeasurementsJSON,
|
initialMeasurementsJSON: initialMeasurementsJSON,
|
||||||
|
getIPAddr: util.GetIPAddr,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,13 +80,13 @@ func (k *KubeWrapper) InitCluster(
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
ip, err := util.GetIPAddr()
|
ip, err := k.getIPAddr()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
nodeName := ip
|
nodeName := ip
|
||||||
var providerID string
|
var providerID string
|
||||||
var instance cloudtypes.Instance
|
var instance metadata.InstanceMetadata
|
||||||
var publicIP string
|
var publicIP string
|
||||||
var nodePodCIDR string
|
var nodePodCIDR string
|
||||||
var subnetworkPodCIDR string
|
var subnetworkPodCIDR string
|
||||||
@ -192,18 +194,21 @@ func (k *KubeWrapper) InitCluster(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// JoinCluster joins existing Kubernetes cluster.
|
// 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
|
// 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
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 1: retrieve cloud metadata for Kubernetes configuration
|
// Step 1: retrieve cloud metadata for Kubernetes configuration
|
||||||
|
nodeInternalIP, err := k.getIPAddr()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
nodeName := nodeInternalIP
|
||||||
var providerID string
|
var providerID string
|
||||||
nodeName := nodeVPNIP
|
|
||||||
nodeInternalIP := nodeVPNIP
|
|
||||||
if k.providerMetadata.Supported() {
|
if k.providerMetadata.Supported() {
|
||||||
instance, err := k.providerMetadata.Self(context.TODO())
|
instance, err := k.providerMetadata.Self(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("retrieving own instance metadata failed: %w", err)
|
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)
|
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() {
|
if !k.cloudControllerManager.Supported() {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -312,7 +317,7 @@ func (k *KubeWrapper) setupCloudNodeManager() error {
|
|||||||
return nil
|
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() {
|
if !k.clusterAutoscaler.Supported() {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
@ -7,11 +7,11 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/edgelesssys/constellation/coordinator/cloudprovider/cloudtypes"
|
"github.com/edgelesssys/constellation/coordinator/internal/kubernetes/k8sapi"
|
||||||
"github.com/edgelesssys/constellation/coordinator/kubernetes/k8sapi"
|
"github.com/edgelesssys/constellation/coordinator/internal/kubernetes/k8sapi/resources"
|
||||||
"github.com/edgelesssys/constellation/coordinator/kubernetes/k8sapi/resources"
|
|
||||||
"github.com/edgelesssys/constellation/coordinator/role"
|
"github.com/edgelesssys/constellation/coordinator/role"
|
||||||
attestationtypes "github.com/edgelesssys/constellation/internal/attestation/types"
|
attestationtypes "github.com/edgelesssys/constellation/internal/attestation/types"
|
||||||
|
"github.com/edgelesssys/constellation/internal/cloud/metadata"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"go.uber.org/goleak"
|
"go.uber.org/goleak"
|
||||||
@ -24,7 +24,6 @@ func TestMain(m *testing.M) {
|
|||||||
|
|
||||||
func TestInitCluster(t *testing.T) {
|
func TestInitCluster(t *testing.T) {
|
||||||
someErr := errors.New("failed")
|
someErr := errors.New("failed")
|
||||||
coordinatorVPNIP := "192.0.2.0"
|
|
||||||
serviceAccountUri := "some-service-account-uri"
|
serviceAccountUri := "some-service-account-uri"
|
||||||
masterSecret := []byte("some-master-secret")
|
masterSecret := []byte("some-master-secret")
|
||||||
autoscalingNodeGroups := []string{"0,10,autoscaling_group_0"}
|
autoscalingNodeGroups := []string{"0,10,autoscaling_group_0"}
|
||||||
@ -64,7 +63,7 @@ func TestInitCluster(t *testing.T) {
|
|||||||
"node-ip": "",
|
"node-ip": "",
|
||||||
"provider-id": "",
|
"provider-id": "",
|
||||||
},
|
},
|
||||||
Name: coordinatorVPNIP,
|
Name: privateIP,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
ClusterConfiguration: kubeadm.ClusterConfiguration{},
|
ClusterConfiguration: kubeadm.ClusterConfiguration{},
|
||||||
@ -77,7 +76,7 @@ func TestInitCluster(t *testing.T) {
|
|||||||
},
|
},
|
||||||
providerMetadata: &stubProviderMetadata{
|
providerMetadata: &stubProviderMetadata{
|
||||||
SupportedResp: true,
|
SupportedResp: true,
|
||||||
SelfResp: cloudtypes.Instance{
|
SelfResp: metadata.InstanceMetadata{
|
||||||
Name: nodeName,
|
Name: nodeName,
|
||||||
ProviderID: providerID,
|
ProviderID: providerID,
|
||||||
PrivateIPs: []string{privateIP},
|
PrivateIPs: []string{privateIP},
|
||||||
@ -267,6 +266,7 @@ func TestInitCluster(t *testing.T) {
|
|||||||
configProvider: &stubConfigProvider{InitConfig: k8sapi.KubeadmInitYAML{}},
|
configProvider: &stubConfigProvider{InitConfig: k8sapi.KubeadmInitYAML{}},
|
||||||
client: &tc.kubeCTL,
|
client: &tc.kubeCTL,
|
||||||
kubeconfigReader: tc.kubeconfigReader,
|
kubeconfigReader: tc.kubeconfigReader,
|
||||||
|
getIPAddr: func() (string, error) { return privateIP, nil },
|
||||||
}
|
}
|
||||||
err := kube.InitCluster(context.Background(), autoscalingNodeGroups, serviceAccountUri, k8sVersion, attestationtypes.ID{}, KMSConfig{MasterSecret: masterSecret}, 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"},
|
CACertHashes: []string{"sha256:a60ebe9b0879090edd83b40a4df4bebb20506bac1e51d518ff8f4505a721930f"},
|
||||||
}
|
}
|
||||||
|
|
||||||
nodeVPNIP := "192.0.2.0"
|
privateIP := "192.0.2.1"
|
||||||
certKey := "cert-key"
|
certKey := "cert-key"
|
||||||
|
|
||||||
testCases := map[string]struct {
|
testCases := map[string]struct {
|
||||||
@ -313,8 +313,8 @@ func TestJoinCluster(t *testing.T) {
|
|||||||
BootstrapToken: joinCommand,
|
BootstrapToken: joinCommand,
|
||||||
},
|
},
|
||||||
NodeRegistration: kubeadm.NodeRegistrationOptions{
|
NodeRegistration: kubeadm.NodeRegistrationOptions{
|
||||||
Name: nodeVPNIP,
|
Name: privateIP,
|
||||||
KubeletExtraArgs: map[string]string{"node-ip": "192.0.2.0"},
|
KubeletExtraArgs: map[string]string{"node-ip": privateIP},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -322,7 +322,7 @@ func TestJoinCluster(t *testing.T) {
|
|||||||
clusterUtil: stubClusterUtil{},
|
clusterUtil: stubClusterUtil{},
|
||||||
providerMetadata: &stubProviderMetadata{
|
providerMetadata: &stubProviderMetadata{
|
||||||
SupportedResp: true,
|
SupportedResp: true,
|
||||||
SelfResp: cloudtypes.Instance{
|
SelfResp: metadata.InstanceMetadata{
|
||||||
ProviderID: "provider-id",
|
ProviderID: "provider-id",
|
||||||
Name: "metadata-name",
|
Name: "metadata-name",
|
||||||
PrivateIPs: []string{"192.0.2.1"},
|
PrivateIPs: []string{"192.0.2.1"},
|
||||||
@ -344,7 +344,7 @@ func TestJoinCluster(t *testing.T) {
|
|||||||
clusterUtil: stubClusterUtil{},
|
clusterUtil: stubClusterUtil{},
|
||||||
providerMetadata: &stubProviderMetadata{
|
providerMetadata: &stubProviderMetadata{
|
||||||
SupportedResp: true,
|
SupportedResp: true,
|
||||||
SelfResp: cloudtypes.Instance{
|
SelfResp: metadata.InstanceMetadata{
|
||||||
ProviderID: "provider-id",
|
ProviderID: "provider-id",
|
||||||
Name: "metadata-name",
|
Name: "metadata-name",
|
||||||
PrivateIPs: []string{"192.0.2.1"},
|
PrivateIPs: []string{"192.0.2.1"},
|
||||||
@ -368,7 +368,7 @@ func TestJoinCluster(t *testing.T) {
|
|||||||
clusterUtil: stubClusterUtil{},
|
clusterUtil: stubClusterUtil{},
|
||||||
providerMetadata: &stubProviderMetadata{
|
providerMetadata: &stubProviderMetadata{
|
||||||
SupportedResp: true,
|
SupportedResp: true,
|
||||||
SelfResp: cloudtypes.Instance{
|
SelfResp: metadata.InstanceMetadata{
|
||||||
ProviderID: "provider-id",
|
ProviderID: "provider-id",
|
||||||
Name: "metadata-name",
|
Name: "metadata-name",
|
||||||
PrivateIPs: []string{"192.0.2.1"},
|
PrivateIPs: []string{"192.0.2.1"},
|
||||||
@ -410,23 +410,6 @@ func TestJoinCluster(t *testing.T) {
|
|||||||
role: role.Node,
|
role: role.Node,
|
||||||
wantErr: true,
|
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 {
|
for name, tc := range testCases {
|
||||||
@ -439,9 +422,10 @@ func TestJoinCluster(t *testing.T) {
|
|||||||
providerMetadata: tc.providerMetadata,
|
providerMetadata: tc.providerMetadata,
|
||||||
cloudControllerManager: tc.CloudControllerManager,
|
cloudControllerManager: tc.CloudControllerManager,
|
||||||
configProvider: &stubConfigProvider{},
|
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 {
|
if tc.wantErr {
|
||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
return
|
return
|
@ -56,7 +56,7 @@ const (
|
|||||||
## Upgrading Kubernetes resources
|
## Upgrading Kubernetes resources
|
||||||
|
|
||||||
During the cluster initialization, multiple Kubernetes resources are deployed. Some of these should be upgraded with Kubernetes.
|
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
|
curl -q https://k8s.gcr.io/v2/autoscaling/cluster-autoscaler/tags/list | jq .tags
|
||||||
|
Loading…
Reference in New Issue
Block a user