From 66ea609a2947182a7c92dbc0efc2fb006ef67d2d Mon Sep 17 00:00:00 2001 From: Jan Chaloupka Date: Tue, 4 Dec 2018 16:36:37 +0100 Subject: [PATCH] Check codec and event recorder for aws-actuator binary Updating `aws.cluster.k8s.io/v1alpha1` to `awsproviderconfig.k8s.io/v1alpha1`. --- clusterctl/examples/aws/cluster.yaml.template | 2 +- cmd/aws-actuator/README.md | 10 +++++----- cmd/aws-actuator/utils/utils.go | 10 ++++++++++ examples/machine-set.yaml | 2 +- examples/machine-with-filters.yaml | 13 +++++++++++-- examples/machine-with-user-data.yaml | 2 +- examples/machine.yaml | 2 +- examples/master-machine.yaml | 2 +- examples/worker-machine.yaml | 2 +- examples/worker-machineset.yaml | 2 +- 10 files changed, 33 insertions(+), 14 deletions(-) diff --git a/clusterctl/examples/aws/cluster.yaml.template b/clusterctl/examples/aws/cluster.yaml.template index c529cba964..0d681a9f70 100644 --- a/clusterctl/examples/aws/cluster.yaml.template +++ b/clusterctl/examples/aws/cluster.yaml.template @@ -11,6 +11,6 @@ spec: serviceDomain: "cluster.local" providerConfig: value: - apiVersion: "aws.cluster.k8s.io/v1alpha1" + apiVersion: "awsproviderconfig.k8s.io/v1alpha1" kind: "AWSClusterProviderConfig" diff --git a/cmd/aws-actuator/README.md b/cmd/aws-actuator/README.md index 7b56e17829..0083df22f6 100644 --- a/cmd/aws-actuator/README.md +++ b/cmd/aws-actuator/README.md @@ -32,7 +32,7 @@ echo "Ahoj" > /tmp/test ``` ```sh -$ ./bin/aws-actuator create -m examples/machine-with-user-data.yaml -c examples/cluster.yaml -u examples/userdata.yml --environment-id UNIQUE_ID +$ ./bin/aws-actuator create --logtostderr -m examples/machine-with-user-data.yaml -c examples/cluster.yaml -u examples/userdata.yml --environment-id UNIQUE_ID DEBU[0000] Describing AMI ami-a9acbbd6 example=create-machine machine=test/aws-actuator-testing-machine Machine creation was successful! InstanceID: i-027681ebf9a842183 ``` @@ -42,7 +42,7 @@ Once the aws instance is created you can run `$ cat /tmp/test` to verify it cont ## Test if aws instance exists based on machine manifest ```sh -$ ./bin/aws-actuator exists -m examples/machine-with-user-data.yaml -c examples/cluster.yaml --environment-id UNIQUE_ID +$ ./bin/aws-actuator exists --logtostderr -m examples/machine-with-user-data.yaml -c examples/cluster.yaml --environment-id UNIQUE_ID DEBU[0000] checking if machine exists example=create-machine machine=test/aws-actuator-testing-machine DEBU[0000] instance exists as "i-027681ebf9a842183" example=create-machine machine=test/aws-actuator-testing-machine Underlying machine's instance exists. @@ -51,7 +51,7 @@ Underlying machine's instance exists. ## Delete aws instance based on machine manifest ```sh -$ ./bin/aws-actuator delete -m examples/machine-with-user-data.yaml -c examples/cluster.yaml --environment-id UNIQUE_ID +$ ./bin/aws-actuator delete --logtostderr -m examples/machine-with-user-data.yaml -c examples/cluster.yaml --environment-id UNIQUE_ID WARN[0000] cleaning up extraneous instance for machine example=create-machine instanceID=i-027681ebf9a842183 launchTime="2018-08-18 15:50:54 +0000 UTC" machine=test/aws-actuator-testing-machine state=running INFO[0000] terminating instance example=create-machine instanceID=i-027681ebf9a842183 machine=test/aws-actuator-testing-machine Machine delete operation was successful. @@ -62,7 +62,7 @@ Machine delete operation was successful. 1. Bootstrap the control plane ```sh -./bin/aws-actuator create -m examples/master-machine.yaml -c examples/cluster.yaml -u examples/master-userdata.yaml --environment-id UNIQUE_ID +./bin/aws-actuator create --logtostderr -m examples/master-machine.yaml -c examples/cluster.yaml -u examples/master-userdata.yaml --environment-id UNIQUE_ID ``` By default networking is enabled on the master machine. You can @@ -103,7 +103,7 @@ $ cat examples/worker-user-data.sh | base64 5. Create the worker node by running: ```sh -$ ./bin/aws-actuator create -m examples/worker-machine.yaml -c examples/cluster.yaml -u examples/worker-userdata.yaml --environment-id UNIQUE_ID +$ ./bin/aws-actuator create --logtostderr -m examples/worker-machine.yaml -c examples/cluster.yaml -u examples/worker-userdata.yaml --environment-id UNIQUE_ID ``` After some time the kubernetes cluster with the control plane (master node) and the worker node gets provisioned diff --git a/cmd/aws-actuator/utils/utils.go b/cmd/aws-actuator/utils/utils.go index 0acb26a633..5990b5aa6c 100644 --- a/cmd/aws-actuator/utils/utils.go +++ b/cmd/aws-actuator/utils/utils.go @@ -9,6 +9,8 @@ import ( apiv1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/runtime" kubernetesfake "k8s.io/client-go/kubernetes/fake" + "k8s.io/client-go/tools/record" + "sigs.k8s.io/cluster-api-provider-aws/pkg/apis/awsproviderconfig/v1alpha1" machineactuator "sigs.k8s.io/cluster-api-provider-aws/pkg/cloud/aws/actuators/machine" "sigs.k8s.io/controller-runtime/pkg/client/fake" ) @@ -25,10 +27,18 @@ func CreateActuator(machine *clusterv1.Machine, awsCredentials *apiv1.Secret, us fakeClient := fake.NewFakeClient(machine) fakeKubeClient := kubernetesfake.NewSimpleClientset(objList...) + codec, err := v1alpha1.NewCodec() + if err != nil { + glog.Fatal(err) + } + params := machineactuator.ActuatorParams{ Client: fakeClient, KubeClient: fakeKubeClient, AwsClientBuilder: awsclient.NewClient, + Codec: codec, + // use empty recorder dropping any event recorded + EventRecorder: &record.FakeRecorder{}, } actuator, err := machineactuator.NewActuator(params) diff --git a/examples/machine-set.yaml b/examples/machine-set.yaml index 0c46be6874..a26266e0a0 100644 --- a/examples/machine-set.yaml +++ b/examples/machine-set.yaml @@ -24,7 +24,7 @@ spec: spec: providerConfig: value: - apiVersion: aws.cluster.k8s.io/v1alpha1 + apiVersion: awsproviderconfig.k8s.io/v1alpha1 kind: AWSMachineProviderConfig ami: # id: ami-060f14ef82deddfc6 diff --git a/examples/machine-with-filters.yaml b/examples/machine-with-filters.yaml index 389342d4c0..7df19b376d 100644 --- a/examples/machine-with-filters.yaml +++ b/examples/machine-with-filters.yaml @@ -12,10 +12,19 @@ metadata: spec: providerConfig: value: - apiVersion: aws.cluster.k8s.io/v1alpha1 + apiVersion: awsproviderconfig.k8s.io/v1alpha1 kind: AWSMachineProviderConfig ami: - id: ami-0518e1ac70d8a3389 + filters: + - name: "image_stage" + values: + - "base" + - name: operating_system + values: + - "rhel" + - name: ready + values: + - "yes" instanceType: m4.large placement: region: eu-west-1 diff --git a/examples/machine-with-user-data.yaml b/examples/machine-with-user-data.yaml index 40889d5190..84bad75d6b 100644 --- a/examples/machine-with-user-data.yaml +++ b/examples/machine-with-user-data.yaml @@ -12,7 +12,7 @@ metadata: spec: providerConfig: value: - apiVersion: aws.cluster.k8s.io/v1alpha1 + apiVersion: awsproviderconfig.k8s.io/v1alpha1 kind: AWSMachineProviderConfig ami: filters: diff --git a/examples/machine.yaml b/examples/machine.yaml index a51aa3188d..ddbc7b9916 100644 --- a/examples/machine.yaml +++ b/examples/machine.yaml @@ -12,7 +12,7 @@ metadata: spec: providerConfig: value: - apiVersion: aws.cluster.k8s.io/v1alpha1 + apiVersion: awsproviderconfig.k8s.io/v1alpha1 kind: AWSMachineProviderConfig ami: # id: ami-060f14ef82deddfc6 diff --git a/examples/master-machine.yaml b/examples/master-machine.yaml index b2e0a0731a..3550765591 100644 --- a/examples/master-machine.yaml +++ b/examples/master-machine.yaml @@ -12,7 +12,7 @@ metadata: spec: providerConfig: value: - apiVersion: aws.cluster.k8s.io/v1alpha1 + apiVersion: awsproviderconfig.k8s.io/v1alpha1 kind: AWSMachineProviderConfig ami: filters: diff --git a/examples/worker-machine.yaml b/examples/worker-machine.yaml index fed11ab3b7..635fc8a5ea 100644 --- a/examples/worker-machine.yaml +++ b/examples/worker-machine.yaml @@ -10,7 +10,7 @@ metadata: spec: providerConfig: value: - apiVersion: aws.cluster.k8s.io/v1alpha1 + apiVersion: awsproviderconfig.k8s.io/v1alpha1 kind: AWSMachineProviderConfig ami: # id: ami-060f14ef82deddfc6 diff --git a/examples/worker-machineset.yaml b/examples/worker-machineset.yaml index 6dbb2a1252..c30ad88083 100644 --- a/examples/worker-machineset.yaml +++ b/examples/worker-machineset.yaml @@ -23,7 +23,7 @@ spec: node-role.kubernetes.io/compute: "" providerConfig: value: - apiVersion: aws.cluster.k8s.io/v1alpha1 + apiVersion: awsproviderconfig.k8s.io/v1alpha1 kind: AWSMachineProviderConfig ami: filters: