[Draft] Add CRUD-Mock aws client for local testing
What is being added?
This Pr adds a mock aws client that supports basic crud (Create, Read, Update, Destroy) operations. This makes it possible to run the Operator without any interactions with an AWS account.
The client itself is implemented here: https://github.com/mrWinston/go-aws-crud-client/tree/main . It currently uses an in-memory database to store and retrieve the various aws objects that the aao interacts with. This means, that upon every start, the client gets wiped clean again.
Some ideas/issues that might be useful to have before using this:
- [ ] multi-account support - currently, there may be conflicts between objects that should live in different accounts.
- [ ] Persist state upon reboots
- [ ] Load initial state from some fixture
How to test
- Create a local test cluster:
kind create cluster
- Run cluster setup steps:
make predeploy-crud
- This is a modified version of the normal
make predeploythat omits every part that requires aws access - start the operator:
make deploy-local-crud
- Then, in another shell, modify the accountpool size so accounts are actually created:
oc -n aws-account-operator patch accountpool -p '{"spec":{"poolSize":5}}' --type=merge zero-size-accountpool
oc -n aws-account-operator get accounts
NAME STATE CLAIMED CLAIM AGE
osd-creds-mgmt-d72m2c Ready 23s
osd-creds-mgmt-mbfjjw Ready 10m
osd-creds-mgmt-qmj5ll Ready 23s
osd-creds-mgmt-sf7jc5 Ready 23s
osd-creds-mgmt-v22nwb Ready 23s
osd-creds-mgmt-xjlsvq Ready 23s
- Then create a namespace and Accountclaim and watch it being reconciled:
oc create ns test
cat << EOF | oc apply -f -
apiVersion: aws.managed.openshift.io/v1alpha1
kind: AccountClaim
metadata:
name: testacct1
namespace: test
spec:
accountLink: ""
aws:
regions:
- name: us-east-1
awsCredentialSecret:
name: "creds"
namespace: "test"
legalEntity:
id: "111111"
name: Test Organization
EOF
oc -n test get accountclaims
NAME STATE ACCOUNT AGE
testacct1 Ready osd-creds-mgmt-v22nwb 18s
oc -n aws-account-operator get accounts
NAME STATE CLAIMED CLAIM AGE
osd-creds-mgmt-5dr4ql Ready 2m16s
osd-creds-mgmt-mbfjjw Ready 15m
osd-creds-mgmt-qmj5ll Ready 5m24s
osd-creds-mgmt-sf7jc5 Ready 5m24s
osd-creds-mgmt-v22nwb Ready true testacct1 5m24s
osd-creds-mgmt-x857dm Ready 2m6s
osd-creds-mgmt-xjlsvq Ready 5m24s
PR needs rebase.
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.
Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all
[APPROVALNOTIFIER] This PR is NOT APPROVED
This pull-request has been approved by: mrWinston Once this PR has been reviewed and has the lgtm label, please assign bergmannf for approval. For more information see the Kubernetes Code Review Process.
The full list of commands accepted by this bot can be found here.
Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment
Issues go stale after 90d of inactivity.
Mark the issue as fresh by commenting /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
Exclude this issue from closing by commenting /lifecycle frozen.
If this issue is safe to close now please do so with /close.
/lifecycle stale
Stale issues rot after 30d of inactivity.
Mark the issue as fresh by commenting /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.
Exclude this issue from closing by commenting /lifecycle frozen.
If this issue is safe to close now please do so with /close.
/lifecycle rotten /remove-lifecycle stale
Rotten issues close after 30d of inactivity.
Reopen the issue by commenting /reopen.
Mark the issue as fresh by commenting /remove-lifecycle rotten.
Exclude this issue from closing again by commenting /lifecycle frozen.
/close
@openshift-bot: Closed this PR.
In response to this:
Rotten issues close after 30d of inactivity.
Reopen the issue by commenting
/reopen. Mark the issue as fresh by commenting/remove-lifecycle rotten. Exclude this issue from closing again by commenting/lifecycle frozen./close
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.