Skip to content

Commit

Permalink
Check codec and event recorder for aws-actuator binary
Browse files Browse the repository at this point in the history
Updating `aws.cluster.k8s.io/v1alpha1` to `awsproviderconfig.k8s.io/v1alpha1`.
  • Loading branch information
ingvagabund committed Dec 4, 2018
1 parent 93c3133 commit 66ea609
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 14 deletions.
2 changes: 1 addition & 1 deletion clusterctl/examples/aws/cluster.yaml.template
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ spec:
serviceDomain: "cluster.local"
providerConfig:
value:
apiVersion: "aws.cluster.k8s.io/v1alpha1"
apiVersion: "awsproviderconfig.k8s.io/v1alpha1"
kind: "AWSClusterProviderConfig"

10 changes: 5 additions & 5 deletions cmd/aws-actuator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions cmd/aws-actuator/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion examples/machine-set.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 11 additions & 2 deletions examples/machine-with-filters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion examples/machine-with-user-data.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ metadata:
spec:
providerConfig:
value:
apiVersion: aws.cluster.k8s.io/v1alpha1
apiVersion: awsproviderconfig.k8s.io/v1alpha1
kind: AWSMachineProviderConfig
ami:
filters:
Expand Down
2 changes: 1 addition & 1 deletion examples/machine.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion examples/master-machine.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ metadata:
spec:
providerConfig:
value:
apiVersion: aws.cluster.k8s.io/v1alpha1
apiVersion: awsproviderconfig.k8s.io/v1alpha1
kind: AWSMachineProviderConfig
ami:
filters:
Expand Down
2 changes: 1 addition & 1 deletion examples/worker-machine.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion examples/worker-machineset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 66ea609

Please sign in to comment.