Skip to content

Commit b8f1f9d

Browse files
authored
Update README.md and other documentations related refactorings (#14)
1 parent 677154c commit b8f1f9d

File tree

7 files changed

+236
-103
lines changed

7 files changed

+236
-103
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# CHANGELOG

CONTRIBUTING.md

Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
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.

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ e2e-test: manifests kustomize kubetest2 fmt vet
7272
build: manifests generate generate-mocks fmt vet ## Build manager binary.
7373
go build -o bin/manager main.go
7474

75-
run: manifests generate fmt vet ## Run a controller from your host.
75+
run: manifests generate generate-mocks fmt vet ## Run a controller from your host.
7676
go run ./main.go
7777

7878
docker-build: test ## Build docker image with the manager.
@@ -81,6 +81,9 @@ docker-build: test ## Build docker image with the manager.
8181
docker-push: ## Push docker image with the manager.
8282
docker push ${IMG}
8383

84+
clean:
85+
rm -rf $(MOCKS_DESTINATION) bin/ testbin/ cover.out
86+
8487
##@ Deployment
8588

8689
install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config.

README.md

Lines changed: 15 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -1,113 +1,26 @@
11
# AWS Cloud Map MCS Controller for K8s
22

3-
AWS Cloud Map MCS Controller for K8s is a controller that implements existing multi-cluster services API that allows services to communicate across multiple clusters. The implementation relies on [AWS Cloud Map](https://aws.amazon.com/cloud-map/) for enabling cross-cluster service discovery.
4-
5-
[![Deploy status](https://github.com/aws/aws-cloud-map-mcs-controller-for-k8s/actions/workflows/deploy.yml/badge.svg)](https://github.com/aws/aws-cloud-map-mcs-controller-for-k8s/actions/workflows/deploy.yml)
63
[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/aws/aws-cloud-map-mcs-controller-for-k8s/issues)
4+
[![License](https://img.shields.io/badge/license-Apache--2.0-blue.svg?color=success)](http://www.apache.org/licenses/LICENSE-2.0)
5+
![GitHub issues](https://img.shields.io/github/issues-raw/aws/aws-cloud-map-mcs-controller-for-k8s?style=flat)
76

8-
# How to build and run
9-
10-
Pre-requisite: Create Private DNS Namespace in Cloud Map `demo`
11-
12-
Set region
13-
```
14-
export AWS_REGION=us-west-2
15-
```
16-
17-
Spin up a local Kubernetes cluster using `kind`
18-
19-
```
20-
kind create cluster
21-
kind export kubeconfig
22-
```
23-
24-
Install custom CRDs (`ServiceImport`, `ServiceExport`) to the cluster
25-
26-
```
27-
make install
28-
```
29-
30-
Run controller
31-
32-
```
33-
make run
34-
```
35-
36-
Create a testing deployment
37-
38-
```
39-
# my-deployment.yaml
40-
apiVersion: apps/v1
41-
kind: Deployment
42-
metadata:
43-
namespace: demo
44-
name: nginx-deployment
45-
labels:
46-
app: nginx
47-
spec:
48-
replicas: 5
49-
selector:
50-
matchLabels:
51-
app: nginx
52-
template:
53-
metadata:
54-
labels:
55-
app: nginx
56-
spec:
57-
containers:
58-
- name: nginx
59-
image: nginx:1.14.2
60-
ports:
61-
- containerPort: 80
62-
```
63-
64-
Create a testing Service
65-
66-
```
67-
# my-service.yaml
68-
kind: Service
69-
apiVersion: v1
70-
metadata:
71-
namespace: demo
72-
name: my-service-name
73-
spec:
74-
selector:
75-
app: nginx
76-
ports:
77-
- port: 8080
78-
targetPort: 80
79-
```
80-
81-
Create a testing ServiceExport resource
7+
[![Deploy status](https://github.com/aws/aws-cloud-map-mcs-controller-for-k8s/actions/workflows/deploy.yml/badge.svg)](https://github.com/aws/aws-cloud-map-mcs-controller-for-k8s/actions/workflows/deploy.yml)
8+
[![Go Report Card](https://goreportcard.com/badge/github.com/aws/aws-cloud-map-mcs-controller-for-k8s)](https://goreportcard.com/report/github.com/aws/aws-cloud-map-mcs-controller-for-k8s)
829

83-
```
84-
# my-export.yaml
10+
## Introduction
11+
AWS Cloud Map multi-cluster service discovery for Kubernetes (K8s) is a controller that implements existing multi-cluster services API that allows services to communicate across multiple clusters. The implementation relies on [AWS Cloud Map](https://aws.amazon.com/cloud-map/) for enabling cross-cluster service discovery.
8512

86-
kind: ServiceExport
87-
apiVersion: multicluster.x-k8s.io/v1alpha1
88-
metadata:
89-
namespace: demo
90-
name: my-service-name
91-
```
13+
## Releases
9214

93-
Apply config files
15+
AWS Cloud Map MCS Controller for K8s adheres to the [SemVer](https://semver.org/) specification. Each release updates the major version tag (eg. `vX`), a major/minor version tag (eg. `vX.Y`) and a major/minor/patch version tag (eg. `vX.Y.Z`). To see a full list of all releases, refer to our [Github releases page](https://github.com/aws/aws-cloud-map-mcs-controller-for-k8s/releases).
9416

95-
```
96-
kubectl create namespace demo
97-
kubectl apply -f my-deployment.yaml
98-
kubectl apply -f my-service.yaml
99-
kubectl apply -f my-export.yaml
100-
```
17+
We also maintain a `latest` tag, which is updated to stay in line with the `main` branch. We **do not** recommend installing this on any production cluster, as any new major versions updated on the `main` branch will introduce breaking changes.
10118

102-
Check running controller if it correctly detects newly created resource
19+
## Contributing
20+
`aws-cloud-map-mcs-controller-for-k8s` is an open source project. See [CONTRIBUTING](https://github.com/aws/aws-cloud-map-mcs-controller-for-k8s/blob/main/CONTRIBUTING.md) for details.
10321

104-
```
105-
2021-07-09T14:31:26.933-0700 INFO controllers.ServiceExport updating Cloud Map service {"serviceexport": "demo/my-service-name", "namespace": "demo", "name": "my-service-name"}
106-
2021-07-09T14:31:26.933-0700 INFO cloudmap fetching a service {"namespaceName": "demo", "serviceName": "my-service-name"}
107-
2021-07-09T14:31:27.341-0700 INFO cloudmap creating a new service {"namespace": "demo", "name": "my-service-name"}
108-
```
22+
## License
10923

110-
# How to generate mocks and run unit tests
111-
```
112-
make test
113-
```
24+
This project is distributed under the
25+
[Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0),
26+
see [LICENSE](https://github.com/aws/aws-cloud-map-mcs-controller-for-k8s/blob/main/LICENSE) and [NOTICE](https://github.com/aws/aws-cloud-map-mcs-controller-for-k8s/blob/main/NOTICE) for more information.

samples/demo-deployment.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
namespace: demo
5+
name: nginx-deployment
6+
labels:
7+
app: nginx
8+
spec:
9+
replicas: 5
10+
selector:
11+
matchLabels:
12+
app: nginx
13+
template:
14+
metadata:
15+
labels:
16+
app: nginx
17+
spec:
18+
containers:
19+
- name: nginx
20+
image: nginx:1.14.2
21+
ports:
22+
- containerPort: 80

samples/demo-export.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
kind: ServiceExport
2+
apiVersion: multicluster.x-k8s.io/v1alpha1
3+
metadata:
4+
namespace: demo
5+
name: demo-service

samples/demo-service.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
kind: Service
2+
apiVersion: v1
3+
metadata:
4+
namespace: demo
5+
name: demo-service
6+
spec:
7+
selector:
8+
app: nginx
9+
ports:
10+
- port: 8080
11+
targetPort: 80

0 commit comments

Comments
 (0)