Rename all activation

This commit is contained in:
katexochen 2022-07-05 14:13:19 +02:00 committed by Paul Meyer
parent 2083d37b11
commit 1af18e990d
21 changed files with 83 additions and 83 deletions

View File

@ -1,4 +1,4 @@
name: Build and upload activation-service image name: Build and upload join-service image
on: on:
workflow_dispatch: workflow_dispatch:
@ -6,7 +6,7 @@ on:
branches: branches:
- main - main
paths: paths:
- "activation/**" - "joinservice/**"
- "internal/atls/**" - "internal/atls/**"
- "internal/attestation/**" - "internal/attestation/**"
- "internal/constants/**" - "internal/constants/**"
@ -20,7 +20,7 @@ concurrency:
cancel-in-progress: true cancel-in-progress: true
jobs: jobs:
build-activation-service: build-join-service:
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions: permissions:
contents: read contents: read
@ -30,11 +30,11 @@ jobs:
id: checkout id: checkout
uses: actions/checkout@v3 uses: actions/checkout@v3
- name: Build and upload activation-service container image - name: Build and upload join-service container image
id: build-and-upload id: build-and-upload
uses: ./.github/actions/build_micro_service uses: ./.github/actions/build_micro_service
with: with:
name: activation-service name: join-service
projectVersion: "0.0.0" projectVersion: '0.0.0'
dockerfile: activation/Dockerfile dockerfile: joinservice/Dockerfile
githubToken: ${{ secrets.GITHUB_TOKEN }} githubToken: ${{ secrets.GITHUB_TOKEN }}

View File

@ -8,7 +8,7 @@ on:
type: choice type: choice
options: options:
- 'access-manager' - 'access-manager'
- 'activation-service' - 'join-service'
- 'kmsserver' - 'kmsserver'
- 'verification-service' - 'verification-service'
required: true required: true
@ -40,15 +40,15 @@ jobs:
case "${{ inputs.microService }}" in case "${{ inputs.microService }}" in
"access-manager" ) "access-manager" )
echo "microServiceDockerfile=access_manager/Dockerfile" >> $GITHUB_ENV ;; echo "microServiceDockerfile=access_manager/Dockerfile" >> $GITHUB_ENV ;;
"activation-service" ) "join-service" )
echo "microServiceDockerfile=activation/Dockerfile" >> $GITHUB_ENV ;; echo "microServiceDockerfile=joinservice/Dockerfile" >> $GITHUB_ENV ;;
"kmsserver" ) "kmsserver" )
echo "microServiceDockerfile=kms/Dockerfile" >> $GITHUB_ENV ;; echo "microServiceDockerfile=kms/Dockerfile" >> $GITHUB_ENV ;;
"verification-service" ) "verification-service" )
echo "microServiceDockerfile=verify/Dockerfile" >> $GITHUB_ENV ;; echo "microServiceDockerfile=verify/Dockerfile" >> $GITHUB_ENV ;;
esac esac
- name: Build and upload activation-service container image - name: Build and upload join-service container image
id: build-and-upload id: build-and-upload
uses: ./.github/actions/build_micro_service uses: ./.github/actions/build_micro_service
with: with:

View File

@ -11,7 +11,7 @@ on:
- "internal/constants/**" - "internal/constants/**"
jobs: jobs:
build-activation-service: build-verification-service:
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions: permissions:
contents: read contents: read

View File

@ -28,12 +28,12 @@ func run(issuer quoteIssuer, tpm vtpm.TPMOpenFunc, fileHandler file.Handler,
defer cloudLogger.Close() defer cloudLogger.Close()
cloudLogger.Disclose("bootstrapper started running...") cloudLogger.Disclose("bootstrapper started running...")
nodeActivated, err := vtpm.IsNodeInitialized(tpm) nodeBootstrapped, err := vtpm.IsNodeBootstrapped(tpm)
if err != nil { if err != nil {
logger.Fatal("failed to check for previous activation using vTPM", zap.Error(err)) logger.Fatal("failed to check for previous bootstrapping using vTPM", zap.Error(err))
} }
if nodeActivated { if nodeBootstrapped {
if err := kube.StartKubelet(); err != nil { if err := kube.StartKubelet(); err != nil {
logger.Fatal("failed to restart kubelet", zap.Error(err)) logger.Fatal("failed to restart kubelet", zap.Error(err))
} }

View File

@ -65,7 +65,7 @@ func New(lock *nodelock.Lock, dial grpcDialer, joiner ClusterJoiner, meta Metada
dialer: dial, dialer: dial,
joiner: joiner, joiner: joiner,
metadataAPI: meta, metadataAPI: meta,
log: log.Named("selfactivation-client"), log: log.Named("join-client"),
} }
} }
@ -116,15 +116,15 @@ func (c *JoinClient) Start() {
} }
for { for {
err := c.tryJoinAtAvailableServices() err := c.tryJoinWithAvailableServices()
if err == nil { if err == nil {
c.log.Info("Activated successfully. SelfActivationClient shut down.") c.log.Info("Joined successfully. Client is shut down.")
return return
} else if isUnrecoverable(err) { } else if isUnrecoverable(err) {
c.log.Error("Unrecoverable error occurred", zap.Error(err)) c.log.Error("Unrecoverable error occurred", zap.Error(err))
return return
} }
c.log.Info("Activation failed for all available endpoints", zap.Error(err)) c.log.Info("Join failed for all available endpoints", zap.Error(err))
c.log.Info("Sleeping", zap.Duration("interval", c.interval)) c.log.Info("Sleeping", zap.Duration("interval", c.interval))
select { select {
@ -156,7 +156,7 @@ func (c *JoinClient) Stop() {
c.log.Info("Stopped") c.log.Info("Stopped")
} }
func (c *JoinClient) tryJoinAtAvailableServices() error { func (c *JoinClient) tryJoinWithAvailableServices() error {
ips, err := c.getControlPlaneIPs() ips, err := c.getControlPlaneIPs()
if err != nil { if err != nil {
return err return err

View File

@ -2,7 +2,7 @@ package resources
const ( const (
// Constellation images. // Constellation images.
activationImage = "ghcr.io/edgelesssys/constellation/activation-service:v1.2" joinImage = "ghcr.io/edgelesssys/constellation/join-service:v1.2"
accessManagerImage = "ghcr.io/edgelesssys/constellation/access-manager:v1.2" accessManagerImage = "ghcr.io/edgelesssys/constellation/access-manager:v1.2"
kmsImage = "ghcr.io/edgelesssys/constellation/kmsserver:v1.2" kmsImage = "ghcr.io/edgelesssys/constellation/kmsserver:v1.2"
verificationImage = "ghcr.io/edgelesssys/constellation/verification-service:v1.2" verificationImage = "ghcr.io/edgelesssys/constellation/verification-service:v1.2"

View File

@ -12,7 +12,7 @@ import (
"k8s.io/apimachinery/pkg/util/intstr" "k8s.io/apimachinery/pkg/util/intstr"
) )
type activationDaemonset struct { type joinServiceDaemonset struct {
ClusterRole rbac.ClusterRole ClusterRole rbac.ClusterRole
ClusterRoleBinding rbac.ClusterRoleBinding ClusterRoleBinding rbac.ClusterRoleBinding
ConfigMap k8s.ConfigMap ConfigMap k8s.ConfigMap
@ -21,18 +21,18 @@ type activationDaemonset struct {
Service k8s.Service Service k8s.Service
} }
// NewActivationDaemonset returns a daemonset for the activation service. // NewJoinServiceDaemonset returns a daemonset for the join service.
func NewActivationDaemonset(csp, measurementsJSON, idJSON string) *activationDaemonset { func NewJoinServiceDaemonset(csp, measurementsJSON, idJSON string) *joinServiceDaemonset {
return &activationDaemonset{ return &joinServiceDaemonset{
ClusterRole: rbac.ClusterRole{ ClusterRole: rbac.ClusterRole{
TypeMeta: meta.TypeMeta{ TypeMeta: meta.TypeMeta{
APIVersion: "rbac.authorization.k8s.io/v1", APIVersion: "rbac.authorization.k8s.io/v1",
Kind: "ClusterRole", Kind: "ClusterRole",
}, },
ObjectMeta: meta.ObjectMeta{ ObjectMeta: meta.ObjectMeta{
Name: "activation-service", Name: "join-service",
Labels: map[string]string{ Labels: map[string]string{
"k8s-app": "activation-service", "k8s-app": "join-service",
}, },
}, },
Rules: []rbac.PolicyRule{ Rules: []rbac.PolicyRule{
@ -54,17 +54,17 @@ func NewActivationDaemonset(csp, measurementsJSON, idJSON string) *activationDae
Kind: "ClusterRoleBinding", Kind: "ClusterRoleBinding",
}, },
ObjectMeta: meta.ObjectMeta{ ObjectMeta: meta.ObjectMeta{
Name: "activation-service", Name: "join-service",
}, },
RoleRef: rbac.RoleRef{ RoleRef: rbac.RoleRef{
APIGroup: "rbac.authorization.k8s.io", APIGroup: "rbac.authorization.k8s.io",
Kind: "ClusterRole", Kind: "ClusterRole",
Name: "activation-service", Name: "join-service",
}, },
Subjects: []rbac.Subject{ Subjects: []rbac.Subject{
{ {
Kind: "ServiceAccount", Kind: "ServiceAccount",
Name: "activation-service", Name: "join-service",
Namespace: "kube-system", Namespace: "kube-system",
}, },
}, },
@ -75,29 +75,29 @@ func NewActivationDaemonset(csp, measurementsJSON, idJSON string) *activationDae
Kind: "DaemonSet", Kind: "DaemonSet",
}, },
ObjectMeta: meta.ObjectMeta{ ObjectMeta: meta.ObjectMeta{
Name: "activation-service", Name: "join-service",
Namespace: "kube-system", Namespace: "kube-system",
Labels: map[string]string{ Labels: map[string]string{
"k8s-app": "activation-service", "k8s-app": "join-service",
"component": "activation-service", "component": "join-service",
"kubernetes.io/cluster-service": "true", "kubernetes.io/cluster-service": "true",
}, },
}, },
Spec: apps.DaemonSetSpec{ Spec: apps.DaemonSetSpec{
Selector: &meta.LabelSelector{ Selector: &meta.LabelSelector{
MatchLabels: map[string]string{ MatchLabels: map[string]string{
"k8s-app": "activation-service", "k8s-app": "join-service",
}, },
}, },
Template: k8s.PodTemplateSpec{ Template: k8s.PodTemplateSpec{
ObjectMeta: meta.ObjectMeta{ ObjectMeta: meta.ObjectMeta{
Labels: map[string]string{ Labels: map[string]string{
"k8s-app": "activation-service", "k8s-app": "join-service",
}, },
}, },
Spec: k8s.PodSpec{ Spec: k8s.PodSpec{
PriorityClassName: "system-cluster-critical", PriorityClassName: "system-cluster-critical",
ServiceAccountName: "activation-service", ServiceAccountName: "join-service",
Tolerations: []k8s.Toleration{ Tolerations: []k8s.Toleration{
{ {
Key: "CriticalAddonsOnly", Key: "CriticalAddonsOnly",
@ -134,11 +134,11 @@ func NewActivationDaemonset(csp, measurementsJSON, idJSON string) *activationDae
}, },
Containers: []k8s.Container{ Containers: []k8s.Container{
{ {
Name: "activation-service", Name: "join-service",
Image: activationImage, Image: joinImage,
Ports: []k8s.ContainerPort{ Ports: []k8s.ContainerPort{
{ {
ContainerPort: constants.ActivationServicePort, ContainerPort: constants.JoinServicePort,
Name: "tcp", Name: "tcp",
}, },
}, },
@ -169,7 +169,7 @@ func NewActivationDaemonset(csp, measurementsJSON, idJSON string) *activationDae
VolumeSource: k8s.VolumeSource{ VolumeSource: k8s.VolumeSource{
ConfigMap: &k8s.ConfigMapVolumeSource{ ConfigMap: &k8s.ConfigMapVolumeSource{
LocalObjectReference: k8s.LocalObjectReference{ LocalObjectReference: k8s.LocalObjectReference{
Name: "activation-config", Name: "join-config",
}, },
}, },
}, },
@ -193,7 +193,7 @@ func NewActivationDaemonset(csp, measurementsJSON, idJSON string) *activationDae
Kind: "ServiceAccount", Kind: "ServiceAccount",
}, },
ObjectMeta: meta.ObjectMeta{ ObjectMeta: meta.ObjectMeta{
Name: "activation-service", Name: "join-service",
Namespace: "kube-system", Namespace: "kube-system",
}, },
}, },
@ -203,7 +203,7 @@ func NewActivationDaemonset(csp, measurementsJSON, idJSON string) *activationDae
Kind: "Service", Kind: "Service",
}, },
ObjectMeta: meta.ObjectMeta{ ObjectMeta: meta.ObjectMeta{
Name: "activation-service", Name: "join-service",
Namespace: "kube-system", Namespace: "kube-system",
}, },
Spec: k8s.ServiceSpec{ Spec: k8s.ServiceSpec{
@ -212,13 +212,13 @@ func NewActivationDaemonset(csp, measurementsJSON, idJSON string) *activationDae
{ {
Name: "grpc", Name: "grpc",
Protocol: k8s.ProtocolTCP, Protocol: k8s.ProtocolTCP,
Port: constants.ActivationServicePort, Port: constants.JoinServicePort,
TargetPort: intstr.IntOrString{IntVal: constants.ActivationServicePort}, TargetPort: intstr.IntOrString{IntVal: constants.JoinServicePort},
NodePort: constants.JoinServiceNodePort, NodePort: constants.JoinServiceNodePort,
}, },
}, },
Selector: map[string]string{ Selector: map[string]string{
"k8s-app": "activation-service", "k8s-app": "join-service",
}, },
}, },
}, },
@ -228,7 +228,7 @@ func NewActivationDaemonset(csp, measurementsJSON, idJSON string) *activationDae
Kind: "ConfigMap", Kind: "ConfigMap",
}, },
ObjectMeta: meta.ObjectMeta{ ObjectMeta: meta.ObjectMeta{
Name: "activation-config", Name: "join-config",
Namespace: "kube-system", Namespace: "kube-system",
}, },
Data: map[string]string{ Data: map[string]string{
@ -240,6 +240,6 @@ func NewActivationDaemonset(csp, measurementsJSON, idJSON string) *activationDae
} }
// Marshal the daemonset using the Kubernetes resource marshaller. // Marshal the daemonset using the Kubernetes resource marshaller.
func (a *activationDaemonset) Marshal() ([]byte, error) { func (a *joinServiceDaemonset) Marshal() ([]byte, error) {
return MarshalK8SResources(a) return MarshalK8SResources(a)
} }

View File

@ -7,12 +7,12 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )
func TestNewActivationDaemonset(t *testing.T) { func TestNewJoinServiceDaemonset(t *testing.T) {
deployment := NewActivationDaemonset("csp", "measurementsJSON", "idJSON") deployment := NewJoinServiceDaemonset("csp", "measurementsJSON", "idJSON")
deploymentYAML, err := deployment.Marshal() deploymentYAML, err := deployment.Marshal()
require.NoError(t, err) require.NoError(t, err)
var recreated activationDaemonset var recreated joinServiceDaemonset
require.NoError(t, UnmarshalK8SResources(deploymentYAML, &recreated)) require.NoError(t, UnmarshalK8SResources(deploymentYAML, &recreated))
assert.Equal(t, deployment, &recreated) assert.Equal(t, deployment, &recreated)
} }

View File

@ -194,7 +194,7 @@ func NewKMSDeployment(csp string, masterSecret []byte) *kmsDeployment {
{ {
ConfigMap: &k8s.ConfigMapProjection{ ConfigMap: &k8s.ConfigMapProjection{
LocalObjectReference: k8s.LocalObjectReference{ LocalObjectReference: k8s.LocalObjectReference{
Name: "activation-config", Name: "join-config",
}, },
Items: []k8s.KeyToPath{ Items: []k8s.KeyToPath{
{ {

View File

@ -232,9 +232,9 @@ func (k *KubernetesUtil) SetupAutoscaling(kubectl Client, clusterAutoscalerConfi
return kubectl.Apply(clusterAutoscalerConfiguration, true) return kubectl.Apply(clusterAutoscalerConfiguration, true)
} }
// SetupActivationService deploys the Constellation node activation service. // SetupJoinService deploys the Constellation node join service.
func (k *KubernetesUtil) SetupActivationService(kubectl Client, activationServiceConfiguration resources.Marshaler) error { func (k *KubernetesUtil) SetupJoinService(kubectl Client, joinServiceConfiguration resources.Marshaler) error {
return kubectl.Apply(activationServiceConfiguration, true) return kubectl.Apply(joinServiceConfiguration, true)
} }
// SetupCloudControllerManager deploys the k8s cloud-controller-manager. // SetupCloudControllerManager deploys the k8s cloud-controller-manager.

View File

@ -16,7 +16,7 @@ type clusterUtil interface {
SetupPodNetwork(context.Context, k8sapi.SetupPodNetworkInput) error SetupPodNetwork(context.Context, k8sapi.SetupPodNetworkInput) error
SetupAccessManager(kubectl k8sapi.Client, sshUsers resources.Marshaler) error SetupAccessManager(kubectl k8sapi.Client, sshUsers resources.Marshaler) error
SetupAutoscaling(kubectl k8sapi.Client, clusterAutoscalerConfiguration resources.Marshaler, secrets resources.Marshaler) error SetupAutoscaling(kubectl k8sapi.Client, clusterAutoscalerConfiguration resources.Marshaler, secrets resources.Marshaler) error
SetupActivationService(kubectl k8sapi.Client, activationServiceConfiguration resources.Marshaler) error SetupJoinService(kubectl k8sapi.Client, joinServiceConfiguration resources.Marshaler) error
SetupCloudControllerManager(kubectl k8sapi.Client, cloudControllerManagerConfiguration resources.Marshaler, configMaps resources.Marshaler, secrets resources.Marshaler) error SetupCloudControllerManager(kubectl k8sapi.Client, cloudControllerManagerConfiguration resources.Marshaler, configMaps resources.Marshaler, secrets resources.Marshaler) error
SetupCloudNodeManager(kubectl k8sapi.Client, cloudNodeManagerConfiguration resources.Marshaler) error SetupCloudNodeManager(kubectl k8sapi.Client, cloudNodeManagerConfiguration resources.Marshaler) error
SetupKMS(kubectl k8sapi.Client, kmsConfiguration resources.Marshaler) error SetupKMS(kubectl k8sapi.Client, kmsConfiguration resources.Marshaler) error

View File

@ -162,8 +162,8 @@ func (k *KubeWrapper) InitCluster(
return nil, fmt.Errorf("setting up kms: %w", err) return nil, fmt.Errorf("setting up kms: %w", err)
} }
if err := k.setupActivationService(k.cloudProvider, k.initialMeasurementsJSON, id); err != nil { if err := k.setupJoinService(k.cloudProvider, k.initialMeasurementsJSON, id); err != nil {
return nil, fmt.Errorf("setting up activation service failed: %w", err) return nil, fmt.Errorf("setting up join service failed: %w", err)
} }
if err := k.setupCCM(ctx, subnetworkPodCIDR, cloudServiceAccountURI, instance); err != nil { if err := k.setupCCM(ctx, subnetworkPodCIDR, cloudServiceAccountURI, instance); err != nil {
@ -268,15 +268,15 @@ func (k *KubeWrapper) GetJoinToken(ctx context.Context, ttl time.Duration) (*kub
return k.clusterUtil.CreateJoinToken(ctx, ttl) return k.clusterUtil.CreateJoinToken(ctx, ttl)
} }
func (k *KubeWrapper) setupActivationService(csp string, measurementsJSON []byte, id attestationtypes.ID) error { func (k *KubeWrapper) setupJoinService(csp string, measurementsJSON []byte, id attestationtypes.ID) error {
idJSON, err := json.Marshal(id) idJSON, err := json.Marshal(id)
if err != nil { if err != nil {
return err return err
} }
activationConfiguration := resources.NewActivationDaemonset(csp, string(measurementsJSON), string(idJSON)) joinConfiguration := resources.NewJoinServiceDaemonset(csp, string(measurementsJSON), string(idJSON))
return k.clusterUtil.SetupActivationService(k.client, activationConfiguration) return k.clusterUtil.SetupJoinService(k.client, joinConfiguration)
} }
func (k *KubeWrapper) setupCCM(ctx context.Context, subnetworkPodCIDR, cloudServiceAccountURI string, instance metadata.InstanceMetadata) error { func (k *KubeWrapper) setupCCM(ctx context.Context, subnetworkPodCIDR, cloudServiceAccountURI string, instance metadata.InstanceMetadata) error {

View File

@ -173,8 +173,8 @@ func TestInitCluster(t *testing.T) {
ClusterAutoscaler: &stubClusterAutoscaler{}, ClusterAutoscaler: &stubClusterAutoscaler{},
wantErr: true, wantErr: true,
}, },
"kubeadm init fails when setting up the activation service": { "kubeadm init fails when setting up the join service": {
clusterUtil: stubClusterUtil{setupActivationServiceError: someErr}, clusterUtil: stubClusterUtil{setupJoinServiceError: someErr},
kubeconfigReader: &stubKubeconfigReader{ kubeconfigReader: &stubKubeconfigReader{
Kubeconfig: []byte("someKubeconfig"), Kubeconfig: []byte("someKubeconfig"),
}, },
@ -506,7 +506,7 @@ type stubClusterUtil struct {
initClusterErr error initClusterErr error
setupPodNetworkErr error setupPodNetworkErr error
setupAutoscalingError error setupAutoscalingError error
setupActivationServiceError error setupJoinServiceError error
setupCloudControllerManagerError error setupCloudControllerManagerError error
setupCloudNodeManagerError error setupCloudNodeManagerError error
setupKMSError error setupKMSError error
@ -539,8 +539,8 @@ func (s *stubClusterUtil) SetupAutoscaling(kubectl k8sapi.Client, clusterAutosca
return s.setupAutoscalingError return s.setupAutoscalingError
} }
func (s *stubClusterUtil) SetupActivationService(kubectl k8sapi.Client, activationServiceConfiguration resources.Marshaler) error { func (s *stubClusterUtil) SetupJoinService(kubectl k8sapi.Client, joinServiceConfiguration resources.Marshaler) error {
return s.setupActivationServiceError return s.setupJoinServiceError
} }
func (s *stubClusterUtil) SetupCloudControllerManager(kubectl k8sapi.Client, cloudControllerManagerConfiguration resources.Marshaler, configMaps resources.Marshaler, secrets resources.Marshaler) error { func (s *stubClusterUtil) SetupCloudControllerManager(kubectl k8sapi.Client, cloudControllerManagerConfiguration resources.Marshaler, configMaps resources.Marshaler, secrets resources.Marshaler) error {

View File

@ -17,8 +17,8 @@ const (
PCRIndexClusterID = tpmutil.Handle(12) PCRIndexClusterID = tpmutil.Handle(12)
) )
// MarkNodeAsInitialized marks a node as initialized by extending PCRs. // MarkNodeAsBootstrapped marks a node as initialized by extending PCRs.
func MarkNodeAsInitialized(openTPM TPMOpenFunc, ownerID, clusterID []byte) error { func MarkNodeAsBootstrapped(openTPM TPMOpenFunc, ownerID, clusterID []byte) error {
tpm, err := openTPM() tpm, err := openTPM()
if err != nil { if err != nil {
return err return err
@ -33,8 +33,8 @@ func MarkNodeAsInitialized(openTPM TPMOpenFunc, ownerID, clusterID []byte) error
return tpm2.PCREvent(tpm, PCRIndexClusterID, clusterID) return tpm2.PCREvent(tpm, PCRIndexClusterID, clusterID)
} }
// IsNodeInitialized checks if a node is already initialized by reading PCRs. // IsNodeBootstrapped checks if a node is already bootestrapped by reading PCRs.
func IsNodeInitialized(openTPM TPMOpenFunc) (bool, error) { func IsNodeBootstrapped(openTPM TPMOpenFunc) (bool, error) {
tpm, err := openTPM() tpm, err := openTPM()
if err != nil { if err != nil {
return false, err return false, err

View File

@ -31,7 +31,7 @@ func TestMarkNodeAsInitialized(t *testing.T) {
pcrs, err := client.ReadAllPCRs(tpm) pcrs, err := client.ReadAllPCRs(tpm)
require.NoError(err) require.NoError(err)
assert.NoError(MarkNodeAsInitialized(func() (io.ReadWriteCloser, error) { assert.NoError(MarkNodeAsBootstrapped(func() (io.ReadWriteCloser, error) {
return &simTPMNOPCloser{tpm}, nil return &simTPMNOPCloser{tpm}, nil
}, []byte{0x0, 0x1, 0x2, 0x3}, []byte{0x4, 0x5, 0x6, 0x7})) }, []byte{0x0, 0x1, 0x2, 0x3}, []byte{0x4, 0x5, 0x6, 0x7}))
@ -47,7 +47,7 @@ func TestMarkNodeAsInitialized(t *testing.T) {
func TestFailOpener(t *testing.T) { func TestFailOpener(t *testing.T) {
assert := assert.New(t) assert := assert.New(t)
assert.Error(MarkNodeAsInitialized(func() (io.ReadWriteCloser, error) { return nil, errors.New("failed") }, []byte{0x0, 0x1, 0x2, 0x3}, []byte{0x0, 0x1, 0x2, 0x3})) assert.Error(MarkNodeAsBootstrapped(func() (io.ReadWriteCloser, error) { return nil, errors.New("failed") }, []byte{0x0, 0x1, 0x2, 0x3}, []byte{0x0, 0x1, 0x2, 0x3}))
} }
func TestIsNodeInitialized(t *testing.T) { func TestIsNodeInitialized(t *testing.T) {
@ -86,7 +86,7 @@ func TestIsNodeInitialized(t *testing.T) {
if tc.pcrValueClusterID != nil { if tc.pcrValueClusterID != nil {
require.NoError(tpm2.PCREvent(tpm, PCRIndexClusterID, tc.pcrValueClusterID)) require.NoError(tpm2.PCREvent(tpm, PCRIndexClusterID, tc.pcrValueClusterID))
} }
initialized, err := IsNodeInitialized(func() (io.ReadWriteCloser, error) { initialized, err := IsNodeBootstrapped(func() (io.ReadWriteCloser, error) {
return &simTPMNOPCloser{tpm}, nil return &simTPMNOPCloser{tpm}, nil
}) })
if tc.wantErr { if tc.wantErr {

View File

@ -14,5 +14,5 @@ func TestMain(m *testing.M) {
func TestNOPTPM(t *testing.T) { func TestNOPTPM(t *testing.T) {
assert := assert.New(t) assert := assert.New(t)
assert.NoError(MarkNodeAsInitialized(OpenNOPTPM, []byte{0x0, 0x1, 0x2, 0x3}, []byte{0x4, 0x5, 0x6, 0x7})) assert.NoError(MarkNodeAsBootstrapped(OpenNOPTPM, []byte{0x0, 0x1, 0x2, 0x3}, []byte{0x4, 0x5, 0x6, 0x7}))
} }

View File

@ -22,9 +22,9 @@ const (
// Ports. // Ports.
// //
// ActivationServiePort is the port for reaching the activation service within Kubernetes. // JoinServicePort is the port for reaching the join service within Kubernetes.
ActivationServicePort = 9090 JoinServicePort = 9090
// JoinServiceNodePort is the port for reaching the activation service outside of Kubernetes. // JoinServiceNodePort is the port for reaching the join service outside of Kubernetes.
JoinServiceNodePort = 30090 JoinServiceNodePort = 30090
VerifyServicePortHTTP = 8080 VerifyServicePortHTTP = 8080
VerifyServicePortGRPC = 9090 VerifyServicePortGRPC = 9090

View File

@ -28,7 +28,7 @@ func main() {
log := logger.New(logger.JSONLog, logger.VerbosityFromInt(*verbosity)) log := logger.New(logger.JSONLog, logger.VerbosityFromInt(*verbosity))
log.With(zap.String("version", constants.VersionInfo), zap.String("cloudProvider", *provider)). log.With(zap.String("version", constants.VersionInfo), zap.String("cloudProvider", *provider)).
Infof("Constellation Node Activation Service") Infof("Constellation Node Join Service")
handler := file.NewHandler(afero.NewOsFs()) handler := file.NewHandler(afero.NewOsFs())
@ -67,7 +67,7 @@ func main() {
} }
}() }()
if err := server.Run(creds, strconv.Itoa(constants.ActivationServicePort)); err != nil { if err := server.Run(creds, strconv.Itoa(constants.JoinServicePort)); err != nil {
log.With(zap.Error(err)).Fatalf("Failed to run server") log.With(zap.Error(err)).Fatalf("Failed to run server")
} }
} }

View File

@ -63,7 +63,7 @@ func (k *Kubeadm) GetJoinToken(ttl time.Duration) (*kubeadm.BootstrapTokenDiscov
} }
token := bootstraptoken.BootstrapToken{ token := bootstraptoken.BootstrapToken{
Token: tokenStr, Token: tokenStr,
Description: "Bootstrap token generated by Constellation's Activation service", Description: "Bootstrap token generated by Constellation's Join service",
TTL: &metav1.Duration{Duration: ttl}, TTL: &metav1.Duration{Duration: ttl},
} }

View File

@ -22,7 +22,7 @@ import (
kubeadmv1 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta3" kubeadmv1 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta3"
) )
// Server implements the core logic of Constellation's node activation service. // Server implements the core logic of Constellation's node join service.
type Server struct { type Server struct {
log *logger.Logger log *logger.Logger
file file.Handler file file.Handler
@ -57,11 +57,11 @@ func (s *Server) Run(creds credentials.TransportCredentials, port string) error
if err != nil { if err != nil {
return fmt.Errorf("failed to listen: %s", err) return fmt.Errorf("failed to listen: %s", err)
} }
s.log.Infof("Starting activation service on %s", lis.Addr().String()) s.log.Infof("Starting join service on %s", lis.Addr().String())
return grpcServer.Serve(lis) return grpcServer.Serve(lis)
} }
// IssueJoinTicket handles activation requests of Constellation nodes. // IssueJoinTicket handles join requests of Constellation nodes.
// A node will receive: // A node will receive:
// - stateful disk encryption key. // - stateful disk encryption key.
// - Kubernetes join token. // - Kubernetes join token.

View File

@ -83,7 +83,7 @@ getKey:
} }
// taint the node as initialized // taint the node as initialized
if err := vtpm.MarkNodeAsInitialized(s.openTPM, ownerID, clusterID); err != nil { if err := vtpm.MarkNodeAsBootstrapped(s.openTPM, ownerID, clusterID); err != nil {
return err return err
} }