|
| 1 | +# Contributing Guidelines |
| 2 | + |
| 3 | +Thank you for your interest in contributing to our project. Whether it's a bug report, new feature, correction, or additional |
| 4 | +documentation, we greatly value feedback and contributions from our community. |
| 5 | + |
| 6 | +Please read through this document before submitting any issues or pull requests to ensure we have all the necessary |
| 7 | +information to effectively respond to your bug report or contribution. |
| 8 | + |
| 9 | +## Getting Started |
| 10 | + |
| 11 | +### Build and Run locally |
| 12 | + |
| 13 | +#### Prerequisites |
| 14 | + |
| 15 | +In order to build and run locally: |
| 16 | + |
| 17 | +* Make sure to have `kubectl` [installed](https://kubernetes.io/docs/tasks/tools/install-kubectl/), at least version `1.15` or above. |
| 18 | +* Make sure to have `kind` [installed](https://kind.sigs.k8s.io/docs/user/quick-start/#installation). |
| 19 | +* Make sure, you have created a [HttpNamespace](https://docs.aws.amazon.com/cloud-map/latest/api/API_CreateHttpNamespace.html) in AWS Cloud Map. The examples below assumes the namespace name to be `demo` |
| 20 | + |
| 21 | +Note that this walk-through assumes throughout to operate in the `us-west-2` region. |
| 22 | + |
| 23 | +```sh |
| 24 | +export AWS_REGION=us-west-2 |
| 25 | +``` |
| 26 | + |
| 27 | +#### Cluster provisioning |
| 28 | + |
| 29 | +Spin up a local Kubernetes cluster using `kind` |
| 30 | +```sh |
| 31 | +kind create cluster --name my-cluster |
| 32 | +# Creating cluster "my-cluster" ... |
| 33 | +# ... |
| 34 | +``` |
| 35 | + |
| 36 | +When completed, set the kubectl context |
| 37 | +```sh |
| 38 | +kind export kubeconfig --name my-cluster |
| 39 | +# Set kubectl context to "kind-my-cluster" |
| 40 | +``` |
| 41 | + |
| 42 | +To register the custom CRDs (`ServiceImport`, `ServiceExport`) in the cluster and create installers |
| 43 | +```sh |
| 44 | +make install |
| 45 | +# ... |
| 46 | +# customresourcedefinition.apiextensions.k8s.io/serviceexports.multicluster.x-k8s.io created |
| 47 | +# customresourcedefinition.apiextensions.k8s.io/serviceimports.multicluster.x-k8s.io created |
| 48 | +``` |
| 49 | + |
| 50 | +To run the controller, run the following command. The controller runs in an infinite loop so open another terminal to create CRDs. |
| 51 | +```sh |
| 52 | +make run |
| 53 | +``` |
| 54 | + |
| 55 | +Create `demo` namespace |
| 56 | +```sh |
| 57 | +kubectl create namespace demo |
| 58 | +# namespace/demo created |
| 59 | +``` |
| 60 | + |
| 61 | +Apply deployment, service and export configs |
| 62 | +```sh |
| 63 | +kubectl apply -f samples/demo-deployment.yaml |
| 64 | +# deployment.apps/nginx-deployment created |
| 65 | +kubectl apply -f samples/demo-service.yaml |
| 66 | +# service/demo-service created |
| 67 | +kubectl apply -f samples/demo-export.yaml |
| 68 | +# serviceexport.multicluster.x-k8s.io/demo-service created |
| 69 | +``` |
| 70 | + |
| 71 | +Check running controller if it correctly detects newly created resources |
| 72 | +``` |
| 73 | +controllers.ServiceExport updating Cloud Map service {"serviceexport": "demo/demo-service", "namespace": "demo", "name": "demo-service"} |
| 74 | +cloudmap fetching a service {"namespaceName": "demo", "serviceName": "demo-service"} |
| 75 | +cloudmap creating a new service {"namespace": "demo", "name": "demo-service"} |
| 76 | +``` |
| 77 | + |
| 78 | +#### Run unit tests |
| 79 | + |
| 80 | +Use command below to run the unit test |
| 81 | +```sh |
| 82 | +make test |
| 83 | +``` |
| 84 | + |
| 85 | +#### Cleanup |
| 86 | + |
| 87 | +Use the command below to clean all the generated files |
| 88 | +```sh |
| 89 | +make clean |
| 90 | +``` |
| 91 | + |
| 92 | +Use the command below to delete the cluster `my-cluster` |
| 93 | +```sh |
| 94 | +kind delete cluster --name my-cluster |
| 95 | +``` |
| 96 | + |
| 97 | +### Deploying to a cluster |
| 98 | + |
| 99 | +You must first push a Docker image containing the changes to a Docker repository like ECR. |
| 100 | + |
| 101 | +### Build and push docker image to ECR |
| 102 | + |
| 103 | +```sh |
| 104 | +make docker-build docker-push IMG=<YOUR ACCOUNT ID>.dkr.ecr.<ECR REGION>.amazonaws.com/<ECR REPOSITORY> |
| 105 | +``` |
| 106 | + |
| 107 | +#### Deployment |
| 108 | + |
| 109 | +You must specify AWS access credentials for the operator. You can do so via environment variables, or by creating them. |
| 110 | + |
| 111 | +Any one of below three options will work: |
| 112 | +```sh |
| 113 | +# With an IAM user. |
| 114 | +make deploy |
| 115 | + |
| 116 | +# Use an existing access key |
| 117 | +OPERATOR_AWS_ACCESS_KEY_ID=xxx OPERATOR_AWS_SECRET_KEY=yyy make deploy |
| 118 | + |
| 119 | +# Use an AWS profile |
| 120 | +OPERATOR_AWS_PROFILE=default make deploy |
| 121 | +``` |
| 122 | + |
| 123 | +#### Uninstallation |
| 124 | + |
| 125 | +To remove the operator from your cluster, run |
| 126 | +```sh |
| 127 | +make undeploy |
| 128 | +``` |
| 129 | + |
| 130 | +## Reporting Bugs/Feature Requests |
| 131 | + |
| 132 | +We welcome you to use the GitHub issue tracker to report bugs or suggest features. |
| 133 | + |
| 134 | +When filing an issue, please check [existing open](https://github.com/aws/aws-cloud-map-mcs-controller-for-k8s/issues), or [recently closed](https://github.com/aws/aws-cloud-map-mcs-controller-for-k8s/issues?utf8=%E2%9C%93&q=is%3Aissue%20is%3Aclosed%20), issues to make sure somebody else hasn't already |
| 135 | +reported the issue. Please try to include as much information as you can. Details like these are incredibly useful: |
| 136 | + |
| 137 | +* A reproducible test case or series of steps |
| 138 | +* The version of our code being used |
| 139 | +* Any modifications you've made relevant to the bug |
| 140 | +* Anything unusual about your environment or deployment |
| 141 | + |
| 142 | +## Contributing via Pull Requests |
| 143 | + |
| 144 | +Contributions via pull requests are much appreciated. Before sending us a pull request, please ensure that: |
| 145 | + |
| 146 | +1. You are working against the latest source on the *main* branch. |
| 147 | +2. You have checked [existing open](https://github.com/aws/aws-cloud-map-mcs-controller-for-k8s/pulls), and [recently closed](https://github.com/aws/aws-cloud-map-mcs-controller-for-k8s/pulls?q=is%3Apr+is%3Aclosed), pull requests to make sure someone else hasn't addressed the problem already. |
| 148 | +3. You have opened an issue to discuss any significant work - we would hate for your time to be wasted. |
| 149 | + |
| 150 | +To send us a pull request, please: |
| 151 | + |
| 152 | +1. Fork the repository. |
| 153 | +2. Modify the source; please focus on the specific change you are contributing. If you also reformat all the code, it will be hard for us to focus on your change. |
| 154 | +3. Ensure local tests pass. |
| 155 | +4. Commit to your fork using clear commit messages. |
| 156 | +5. Send us a pull request, answering any default questions in the pull request interface. |
| 157 | +6. Pay attention to any automated CI failures reported in the pull request, and stay involved in the conversation. |
| 158 | + |
| 159 | +GitHub provides additional document on [forking a repository](https://help.github.com/articles/fork-a-repo/) and |
| 160 | +[creating a pull request](https://help.github.com/articles/creating-a-pull-request/). |
| 161 | + |
| 162 | +## Finding contributions to work on |
| 163 | + |
| 164 | +Looking at the existing issues is a great way to find something to contribute on. As our projects, by default, use the default GitHub issue labels (enhancement/bug/duplicate/help wanted/invalid/question/wontfix), looking at any ["help wanted"](https://github.com/aws/aws-cloud-map-mcs-controller-for-k8s/labels/help%20wanted) issues is a great place to start. |
| 165 | + |
| 166 | +## Code of Conduct |
| 167 | + |
| 168 | +This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct). |
| 169 | +For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact |
| 170 | +[[email protected]](mailto:[email protected]) with any additional questions or comments. |
| 171 | + |
| 172 | +## Security issue notifications |
| 173 | + |
| 174 | +If you discover a potential security issue in this project we ask that you notify AWS/Amazon Security via our [vulnerability reporting page ](http://aws.amazon.com/security/vulnerability-reporting/) or [email AWS security directly ](mailto:[email protected]). Please do **not ** create a public github issue. |
| 175 | + |
| 176 | +## Licensing |
| 177 | + |
| 178 | +See the [LICENSE](https://github.com/aws/aws-cloud-map-mcs-controller-for-k8s/blob/master/LICENSE) file for our project's licensing. We will ask you to confirm the licensing of your contribution. |
0 commit comments