Skip to content

Commit cb06a0e

Browse files
author
Ignacy Osetek
committed
Convert Python develop script into Helm Chart
Previously, AWI Project was installed using a Python script that took care of: * preparing secrets * initializing private registry * deploying k8s manifests for: - awi-grpc-catalyst-sdwan - awi-ui - awi-infra-guard - envoy-proxy * spawning k8s operator (kube-awi) The newer version of awi-install uses helm charts. This change includes two major charts: * regular chart for awi-grpc-catalyst-sdwan, awi-ui, awi-infra-guard, envoy-proxy * automatically generated chart with helmify Also added a README.md with instructions how to deploy awi project and how to update helm charts and additionally added Makefile scripts. Part of old deploy script remained under create_registry.py and generate_secrets.py as helpers.
1 parent db2a739 commit cb06a0e

43 files changed

Lines changed: 2616 additions & 739 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
bin/
12
out/
23
**/__pycache__/

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[submodule "kube-awi"]
22
path = kube-awi
3-
url = git@wwwin-github.cisco.com:ausm/kube-awi.git
3+
url = https://github.com/app-net-interface/kube-awi.git

Makefile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
LOCALBIN ?= $(shell pwd)/bin
2+
$(LOCALBIN):
3+
mkdir -p $(LOCALBIN)
4+
5+
KUBEBIN ?= $(shell pwd)/kube-awi/bin
6+
HELMIFY ?= $(LOCALBIN)/helmify
7+
KUSTOMIZE ?= $(KUBEBIN)/kustomize
8+
9+
.PHONY: init-submodules
10+
init-submodules:
11+
git submodule update --init --recursive
12+
13+
.PHONY: helmify
14+
helmify: $(HELMIFY) ## Download helmify locally if necessary.
15+
$(HELMIFY): $(LOCALBIN)
16+
test -s $(LOCALBIN)/helmify || GOBIN=$(LOCALBIN) go install github.com/arttor/helmify/cmd/helmify@v0.4.11
17+
18+
.PHONY: build-operator-chart
19+
build-operator-chart: helmify
20+
$(MAKE) -C kube-awi manifests kustomize
21+
$(KUSTOMIZE) build kube-awi/config/default | $(HELMIFY) awi-operator

README.md

Lines changed: 261 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,53 +4,288 @@ The AWI Install repository was created to simplify the process of installing AWI
44
AWI can be easily installed on any k8s cluster - either local one created with minikube,
55
kind or k3d or the ones such as EKS or GKE.
66

7-
In the future, there will be also available a docker compose file for installing AWI
8-
without the need for k8s at all.
7+
# Prerequisites
98

10-
## Prerequisites
9+
Installing App Net Interface requires:
1110

12-
In order to install AWI, the following things needs to be installed:
13-
14-
* Python3
15-
* Python3 dependencies - the script requires installed dependencies from
16-
`requirements.txt`
17-
* AWS CLI - for authenticating cluster with private registry, where our
18-
images are stored - it needs to be configured with access key
19-
* kubectl - for interacting with our cluster, where AWI will be installed
2011
* k8s cluster - it can be either local cluster installed with minikube or any
2112
other tool or external cluster from AWS/GCP etc. which you will have access
2213
with your kubectl
23-
* go compiler - for initializing kubernetes operator (if needed)
24-
* access to `app-net-interface` repositories
2514

26-
You need to install python3 dependencies for your project. You can do it by running
15+
* credentials - depending on the details of controller in use, several secrets
16+
may be required. More about them [here](#creating-secrets)
17+
18+
* kubectl - for creating k8s secrets
19+
20+
* helm - for deploying App-Net-Interface on a cluster
21+
22+
# Running App Net Interface
23+
24+
Installing App Net Interface on your cluster involves a few steps
25+
26+
1. Creating necessary secrets in your k8s cluster
27+
1. Setting up private registry if required
28+
1. Deploying App-Net-Interface using Helm
29+
30+
## Creating Secrets
31+
32+
Before deploying App Net Interface, the administrator should create all
33+
necessary secrets first. App Net Interface manifests are prepared to
34+
expect certain secrets so if those are not provided, the k8s pods will
35+
fail to initialize.
36+
37+
**Each secret value needs to be base64 encoded.**
38+
39+
For instance, a secret `catalyst-sdwan-credentials` which requires username and
40+
password set to admin/password123 will look like this:
41+
42+
```yaml
43+
apiVersion: v1
44+
kind: Secret
45+
metadata:
46+
name: catalyst-sdwan-credentials
47+
type: Opaque
48+
data:
49+
username: "YWRtaW4K"
50+
password: "cGFzc3dvcmQxMjMK"
51+
```
52+
53+
Such secret can be later deployed running
54+
55+
```
56+
kubectl apply -f YAML_FILE -n NAMESPACE
57+
```
58+
59+
**Secrets needs to be stored in the same namespace where App Net Interface**
60+
**will be deployed!**
61+
62+
Current App Net Interface defines following secrets.
63+
64+
* catalyst sdwan credentials
65+
* cloud provider's credentials
66+
* ui credentials
67+
* kubernetes context
2768

28-
```sh
29-
pip3 install -r requirements.txt
69+
Currently, there are no mandatory credentials. Depending on the App Net
70+
Interface configuration, some of them are required and some not.
71+
72+
### Catalyst SDWAN Credentials
73+
74+
Needed when App Net Interface uses Catalyst SDWAN as a connector
75+
76+
```yaml
77+
apiVersion: v1
78+
kind: Secret
79+
metadata:
80+
name: catalyst-sdwan-credentials
81+
type: Opaque
82+
data:
83+
username: "{CATALYST_SDWAN_USERNAME}"
84+
password: "{CATALYST_SDWAN_PASSWORD}"
85+
```
86+
87+
### Provider specific credentials
88+
89+
If the App Net Interface connector is set to AWI, the administrator
90+
needs to provide secrets required for using AWS/GCP providers.
91+
92+
The AWS secret currently expects base64 encoded `credentials` file
93+
such as `$HOME/.aws/credentials`:
94+
95+
```ini
96+
[default]
97+
aws_access_key_id = KEY
98+
aws_secret_access_key = VALUE
3099
```
31100

32-
It is suggested to use `virtualenv` for that
101+
and such base64 encoded file should be placed inside a following secret:
102+
103+
```yaml
104+
apiVersion: v1
105+
kind: Secret
106+
metadata:
107+
name: aws-credentials
108+
type: Opaque
109+
data:
110+
credentials: "{FILE_ENCODED}"
111+
```
33112

34-
## Deployment
113+
Similarly, GCP credentials also require base64 encoded file, which can be
114+
found under `$HOME/.config/gcloud`. The example file content:
35115

36-
To run the deployment simply run:
116+
**Service Account is required.**
37117

38-
```sh
39-
python3 deploy.py
118+
```json
119+
{
120+
"client_email": "CLIENT_EMAIL",
121+
"client_id": "CLIENT_ID",
122+
"private_key": "PRIVATE_KEY",
123+
"private_key_id": "PRIVATE_KEY_ID",
124+
"token_uri": "TOKEN_URI",
125+
"type": "service_account"
126+
}
40127
```
41128

42-
To learn how to provide proper secrets to the project check the script helper
129+
And such base64 encoded file should be put in following secret:
43130

44-
```sh
45-
python3 deploy.py -h
131+
```yaml
132+
apiVersion: v1
133+
kind: Secret
134+
metadata:
135+
name: gcp-credentials
136+
type: Opaque
137+
data:
138+
gcp-key.json: "{FILE_ENCODED}"
46139
```
47140

48-
## Contributing
141+
### Cluster Context
142+
143+
If the administrator wants App Net Interface to be able to interact with
144+
k8s cluster (discovery process or creating connections to pods) the kubeconfig
145+
file needs to be provided as a secret (base64 encoded):
146+
147+
```yaml
148+
apiVersion: v1
149+
kind: Secret
150+
metadata:
151+
name: kube-config
152+
type: Opaque
153+
data:
154+
config: "{FILE_ENCODED}"
155+
```
156+
157+
### UI Credentials
158+
159+
Currently, UI credentials are completely optional even if UI
160+
is spawned. The UI expects:
161+
162+
* GOOGLE_MAPS_API_KEY
163+
* IP2LOCATION_API_KEY
164+
165+
for geographic data purposes but these are not mandatory and not
166+
required for the UI to work with App Net Interface
167+
168+
```yaml
169+
apiVersion: v1
170+
kind: Secret
171+
metadata:
172+
name: awi-ui-keys
173+
type: Opaque
174+
data:
175+
google_maps_api_key: "{GOOGLE_MAPS_API_KEY}"
176+
ip2_location_api_key: "{IP2LOCATION_API_KEY}"
177+
```
178+
179+
## Setting up Private Registry
180+
181+
This step is required if App Net Interface will use a private
182+
registry to pull images.
183+
184+
To use private registry it is important to override default
185+
values to explicitely mention that private registry is in use
186+
and what is the name of such registry.
187+
188+
Creating your own registry rather than using registries such
189+
as gcr.io etc. may require additional steps.
190+
191+
### Example command for creating AWS Registry
192+
193+
```bash
194+
kubectl create secret docker-registry ausm-private-registry \
195+
-n NAMESPACE \
196+
--docker-server=REGISTRY.dkr.ecr.us-west-2.amazonaws.com \
197+
--docker-username=AWS \
198+
--docker-password="$(aws ecr get-login-password --region us-west-2)"
199+
```
200+
201+
### Example command for creating GHCR Registry
202+
203+
```bash
204+
kubectl create secret docker-registry ausm-private-registry \
205+
-n NAMESPACE \
206+
--docker-server=ghcr.io \
207+
--docker-username=GITHUB_USERNAME \
208+
--docker-password=GHCR_PAT \
209+
--docker-email=your-email@example.com
210+
```
211+
212+
## Deploying App Net Interface using Helm
213+
214+
After you've created necessary secrets and optional private registry
215+
secret, you can install awi on your cluster using helm.
216+
217+
To install it from local repository, go to `awi-install/helm` directory
218+
and type:
219+
220+
```
221+
helm install awi . --namespace awi-system
222+
```
223+
224+
# Building chart
225+
226+
## Chart overview
227+
228+
The AWI project consists of two charts:
229+
230+
1. main chart - the chart containing manifests for most of AWI components that include:
231+
232+
* AWI GRPC Catalyst Sdwan - the main operational controller
233+
* AWI Infra Guard - component responsible for setting connections using AWI connector
234+
* AWI UI - the front-end for the application
235+
* Envoy Proxy - a proxy image for forwarding requests to proper targets and handling
236+
WebGRPC protocol used by the UI
237+
238+
1. operator chart - the second chart responsible for kube-awi component that allows
239+
spawning k8s operator and necessary CRDs
240+
241+
## Building
242+
243+
Creating a new `main chart` simply requires updating templates, `Chart.yaml` and `values.yaml`
244+
according to your needs, however `operator chart` involves a few different steps.
245+
246+
### Operator Chart
247+
248+
The `operator chart` is built automatically from the `kube-awi` repository using `helmify`
249+
tool. If the kube-awi repository did not change, there should be no need in rebuilding
250+
operator chart.
251+
252+
If the operator chart needs to be refreshed:
253+
254+
1. Initialize submodules to download kube-awi repository
255+
256+
```
257+
make init-submodules
258+
```
259+
260+
1. Ensure kube-awi is recent
261+
262+
```
263+
cd kube-awi
264+
git checkout main
265+
git pull origin main
266+
cd ..
267+
```
268+
269+
1. Make sure kube-awi is kustomized accodringly to the project needs. If not, enter
270+
kube-awi directory, kustomize it and optionally commit changes.
271+
272+
The project's production kustomize configuration should be commited so this step
273+
is mostly for building custom charts.
274+
275+
1. Generate chart
276+
277+
```
278+
make build-operator-graph
279+
```
280+
281+
1. Update `main chart` Chart.yaml with a new dependency version of your operator chart
282+
283+
# Contributing
49284

50285
Thank you for interest in contributing! Please refer to our
51286
[contributing guide](CONTRIBUTING.md).
52287

53-
## License
288+
# License
54289

55290
awi-install is free and open-source software licensed under the *Apache 2.0*
56291
License.

awi-operator/.helmignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*.orig
18+
*~
19+
# Various IDEs
20+
.project
21+
.idea/
22+
*.tmproj
23+
.vscode/

awi-operator/Chart.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
apiVersion: v2
2+
name: awi-operator
3+
description: A Helm chart for Kubernetes
4+
# A chart can be either an 'application' or a 'library' chart.
5+
#
6+
# Application charts are a collection of templates that can be packaged into versioned archives
7+
# to be deployed.
8+
#
9+
# Library charts provide useful utilities or functions for the chart developer. They're included as
10+
# a dependency of application charts to inject those utilities and functions into the rendering
11+
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
12+
type: application
13+
# This is the chart version. This version number should be incremented each time you make changes
14+
# to the chart and its templates, including the app version.
15+
# Versions are expected to follow Semantic Versioning (https://semver.org/)
16+
version: 0.1.0
17+
# This is the version number of the application being deployed. This version number should be
18+
# incremented each time you make changes to the application. Versions are not expected to
19+
# follow Semantic Versioning. They should reflect the version the application is using.
20+
# It is recommended to use it with quotes.
21+
appVersion: "0.1.0"

0 commit comments

Comments
 (0)