Skip to content

Commit 8863495

Browse files
authored
Add README for chart deployment and values override files for EKS and GKE (#125)
1 parent 16b5f3a commit 8863495

File tree

6 files changed

+368
-3
lines changed

6 files changed

+368
-3
lines changed

charts/whatsapp-proxy-chart/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ type: application
1717
# This is the chart version. This version number should be incremented each time you make changes
1818
# to the chart and its templates, including the app version.
1919
# Versions are expected to follow Semantic Versioning (https://semver.org/)
20-
version: 1.0.1
20+
version: 1.0.2
2121

2222
# This is the version number of the application being deployed. This version number should be
2323
# incremented each time you make changes to the application. Versions are not expected to
Lines changed: 323 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,323 @@
1+
# Chart Deployment
2+
This document explains how to create a Kuberentes cluster in one of the popular public cloud providers (e.g. AWS, GCP), and deploy the WhatsApp proxy Helm chart to your Kubernetes cluster.
3+
4+
## Prerequisites
5+
6+
### Helm
7+
8+
Install Helm using one of the methods outlined in this page: https://helm.sh/docs/intro/install/
9+
10+
## Create a Kubernetes cluster
11+
To deploy your Helm chart, you will first need to create a Kubernetes cluster. You can create a simple Kubernetes cluster on a single server using one of the following tools:
12+
13+
* minikube (https://minikube.sigs.k8s.io/)
14+
* microk8s (https://microk8s.io/)
15+
* K3s (https://k3s.io/)
16+
* kind (https://kind.sigs.k8s.io/)
17+
18+
These single-node Kubernetes clusters are relatively straightforward to set up, and are therefore not discussed here further. To see installation steps, please follow the links provided for each of the tools above.
19+
20+
The rest of the document will explain how to create a Kubernetes cluster on a managed Kubernetes service from one of the public cloud providers, such as:
21+
22+
* AWS: Amazon EKS (Elastic Kubernetes Service)
23+
* GCP: GKE (Google Kubernetes Engine)
24+
25+
### Create a Kubernetes cluster on Amazon Elastic Kubernetes Service (EKS)
26+
To create a Kubernetes cluster on Amazon EKS, you will need an AWS account: https://aws.amazon.com/
27+
28+
#### Install AWS CLI
29+
30+
Once you have created an AWS account, download the AWS CLI tool by following the steps for your operating system as outlined in this page: https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html#getting-started-install-instructions
31+
32+
Once the AWS CLI tool has been installed, you will need to configure it. You will first need an access key for your AWS user account. If you don't have an access key ID and secret access key pair to use, follow the steps below:
33+
34+
1. Go to https://console.aws.amazon.com/iamv2/home#/users.
35+
2. In the list of users, click on your user name.
36+
3. Go to the 'security credentials' tab.
37+
4. Under 'Access keys', click 'Create access key'. If that button is grayed out and there are already two existing keys, then you already have two active access keys. Either use one of those keys, or delete one and create a new key.
38+
5. In the dialog box that opens, make sure to download the CSV file that contains your access key ID and secret access key, as the secret access key is only displayed to you once.
39+
40+
Now, in a terminal window, type:
41+
42+
```
43+
aws configure
44+
```
45+
46+
Follow the steps to enter your access key ID and secret access key. Enter the region that you will be using (if you are unsure, you can use `us-east-1`). For output type, use `json`.
47+
48+
#### Install eksctl
49+
50+
Next, you will need to install the `eksctl` command-line tool. This tool will help you create a Kubernetes cluster.
51+
52+
> **Note**: You can also use the AWS Management Console to create a Kubernetes cluster. However, depending on the configuration parameters you select during cluster creation, you may have issues connecting to your cluster using the `kubectl` tool. This is due to the way EKS assigns the cluster creator identity when creating the cluster through the AWS Management Console, and requires that the identity accessing the cluster be the same as the cluster creator identity. By using the `eksctl` tool to create the cluster, you will not have issues accessing the cluster using `kubectl`. Therefore, in this document, we will be using `eksctl` to create the cluster.
53+
>
54+
> For more information on this issue, see https://docs.aws.amazon.com/eks/latest/userguide/troubleshooting.html#unauthorized
55+
56+
Install the `eksctl` tool for your operating system as outlined in this page: https://docs.aws.amazon.com/eks/latest/userguide/eksctl.html
57+
58+
#### Create your Kubernetes cluster
59+
60+
To create your Kubernetes cluster, run the following command:
61+
62+
```
63+
eksctl create cluster --name <cluster_name> --region <region_code>
64+
```
65+
66+
Replace `<cluster_name>` with a name of your choosing for your Kubernetes cluster, and `<region_code>` with the name of the region that you chose to use in AWS (e.g. `us-east-1`).
67+
68+
**Note**: This step will take about 15-20 minutes to complete. The logs will show the status of the cluster creation process.
69+
70+
**Note**: If you get an error like below:
71+
72+
```
73+
Cannot create cluster 'sample-cluster' because us-east-1d, the targeted availability zone, does not currently have sufficient capacity to support the cluster. Retry and choose from these availability zones: us-east-1a, us-east-1b, us-east-1c
74+
```
75+
76+
Rerun the above command, adding the `--zones` paramter with at least two availability zones from the list of suggested availability zones shown in the error. Your modified command should look similar to the following:
77+
78+
```
79+
eksctl create cluster --name <cluster_name> --region <region_code> --zones us-east-1a,us-east-1b
80+
```
81+
82+
#### Install kubectl
83+
84+
Next, you will need to install the `kubectl` tool. `kubectl` is your main point of interaction with your Kubenernetes cluster, once you create your cluster.
85+
86+
Follow the instructions for your operating system as outlined in this page: https://kubernetes.io/docs/tasks/tools/
87+
88+
> **Important**: The version of `kubectl` you install is important. The minor version of the installed `kubectl` cannot be more than 1 version different from your Kubernetes cluster version.
89+
>
90+
> You can check the version of your Kubernetes cluster in EKS by going to https://console.aws.amazon.com/eks/. In the list, you can see the Kubernetes version for your cluster.
91+
>
92+
> For example, if your cluster's Kubernetes version is 1.23, the `kubectl` version that you install cannot be lower than 1.22.x or higher than 1.24.x. You should always install the latest version of `kubectl` that is compatible with your Kubernetes cluster, so in this case, the latest `kubectl` version that you can install is 1.24.9.
93+
94+
#### Connect `kubectl` to your Kubernetes cluster
95+
96+
To access your Kubernetes from `kubectl`, run the following command:
97+
98+
```
99+
aws eks --region <region_code> update-kubeconfig --name <cluster_name>
100+
```
101+
102+
Replace `<region_code>` with the name of the AWS region you used, and `<cluster_name>` with the name of the cluster you created.
103+
104+
If this command was successful, you should now be able to access your Kubernetes cluster using `kubectl`. Run the following command:
105+
106+
```
107+
kubectl get svc
108+
```
109+
110+
You should get an output like the following:
111+
112+
```
113+
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
114+
kubernetes ClusterIP 10.100.0.1 <none> 443/TCP 2d15h
115+
```
116+
117+
#### Install the AWS Load Balancer Controller
118+
119+
To enable public access to the proxy service, Amazon EKS can deploy an AWS Network Load Balancer for the Kubernetes Service resource. To do so, you will need to install the AWS Load Balancer Controller. To learn more, see the home page for the AWS Load Balancer Controller project: https://kubernetes-sigs.github.io/aws-load-balancer-controller/v2.4/
120+
121+
We will need to install the AWS Load Balancer Controller add-on, as outlined in this page: https://docs.aws.amazon.com/eks/latest/userguide/aws-load-balancer-controller.html
122+
123+
First, download the IAM policy file:
124+
125+
```
126+
curl -O https://raw.githubusercontent.com/kubernetes-sigs/aws-load-balancer-controller/v2.4.6/docs/install/iam_policy.json
127+
```
128+
129+
Next, create an IAM policy using the file that you downloaded, by running the following command:
130+
131+
```
132+
aws iam create-policy \
133+
--policy-name AWSLoadBalancerControllerIAMPolicy \
134+
--policy-document file://iam_policy.json
135+
```
136+
137+
Then, create a service account role for the load balancer controller, by running the following command:
138+
139+
```
140+
eksctl create iamserviceaccount \
141+
--cluster=<cluster_name> \
142+
--namespace=kube-system \
143+
--name=aws-load-balancer-controller \
144+
--role-name AmazonEKSLoadBalancerControllerRole \
145+
--attach-policy-arn=arn:aws:iam::111122223333:policy/AWSLoadBalancerControllerIAMPolicy \
146+
--approve
147+
```
148+
149+
In the above command, replace `<cluster_name>` with the name of your cluster and `111122223333` with your account ID.
150+
151+
Next, add the `eks-charts` repository to helm as follows:
152+
153+
```
154+
helm repo add eks https://aws.github.io/eks-charts
155+
```
156+
157+
Update your local helm repository index as follows:
158+
159+
```
160+
helm repo update
161+
```
162+
163+
Finally, run the following command to install the AWS Load Balancer Controller add-on:
164+
165+
```
166+
helm install aws-load-balancer-controller eks/aws-load-balancer-controller \
167+
-n kube-system \
168+
--set clusterName=<cluster_name> \
169+
--set serviceAccount.create=false \
170+
--set serviceAccount.name=aws-load-balancer-controller
171+
```
172+
173+
Replace `<cluster_name>` with the name of your cluster.
174+
175+
> **Note**: If the AWS region you are using is not `us-west-2`, add this line to the command:
176+
>
177+
> `--set image.repository=602401143452.dkr.ecr.region-code.amazonaws.com/amazon/aws-load-balancer-controller`
178+
>
179+
> Replace `602401143452` with the registry code for your region (find the registry code from the list [here](https://docs.aws.amazon.com/eks/latest/userguide/add-ons-images.html)), and replace `region-code` with the name of the AWS region you are using.
180+
>
181+
> For example, if you are using region `us-east-1`, the command you run should look like the following:
182+
> ```
183+
> helm install aws-load-balancer-controller eks/aws-load-balancer-controller \
184+
> -n kube-system \
185+
> --set clusterName=<cluster_name> \
186+
> --set serviceAccount.create=false \
187+
> --set serviceAccount.name=aws-load-balancer-controller \
188+
> --set image.repository=602401143452.dkr.ecr.us-east-1.amazonaws.com/amazon/aws-load-balancer-controller
189+
> ```
190+
191+
If the previous command was successful, the running the following:
192+
193+
```
194+
kubectl get deployment -n kube-system aws-load-balancer-controller
195+
```
196+
197+
You should see an output like the following:
198+
199+
```
200+
NAME READY UP-TO-DATE AVAILABLE AGE
201+
aws-load-balancer-controller 2/2 2 2 84s
202+
```
203+
204+
Your Kubernetes cluster is now ready for deployments.
205+
206+
### Create a Kubernetes cluster on Google Kubernetes Engine (GKE)
207+
208+
To create a Kubernetes cluster on Google Kubernetes Engine, you will need a Google Cloud Platform account. Go to https://console.cloud.google.com/ to create an account.
209+
210+
#### Install `gcloud` CLI
211+
212+
First, start by installing the `gcloud` CLI tool. Follow the instructions for your operatint systems as outlined on this page: https://cloud.google.com/sdk/docs/install
213+
214+
Once `gcloud` has been installed, run the following command to authenticate the tool with your account:
215+
216+
```
217+
gcloud auth login
218+
```
219+
220+
Follow the steps in the browser window that opens to log in to your Google Cloud Platform account, and give permissions to the `gcloud` CLI tool to access your account.
221+
222+
#### Create a Kubernetes cluster on GKE
223+
224+
To create a Kubernetes cluter on GKE, we can use either the Google Cloud console, or the `gcloud` CLI tool. In this document, we will use the Google Cloud console.
225+
226+
1. Go to https://console.cloud.google.com/kubernetes.
227+
* If you see an 'Enable API' button, click it.
228+
2. Once the GKE dashboard shows, click the 'Create' button at the top of the page.
229+
3. GKE gives you two options for Kubernetes cluster creation and management: Standard and Autopilot. In this document, we will choose Standard. Click the 'Configure' button next to Standard.
230+
4. In the next page, give your Kubernetes cluster a name.
231+
5. Under 'Location type', if 'Zonal' is selected, note the selected zone name. If 'Regional' is selected, note the selected region name.
232+
6. For the purposes of this document, you can leave the other options unchanged.
233+
7. Click 'Create'.
234+
235+
It will take a few minutes for GKE to create the Kubernetes cluster.
236+
237+
Once the Kubernetes cluster has been created, continue to the next section.
238+
239+
#### Install kubectl
240+
241+
Next, you will need to install the `kubectl` tool. `kubectl` is your main point of interaction with your Kubenernetes cluster, once you create your cluster.
242+
243+
Follow the instructions for your operating system as outlined in this page: https://kubernetes.io/docs/tasks/tools/
244+
245+
> **Important**: The version of `kubectl` you install is important. The minor version of the installed `kubectl` cannot be more than 1 version different from your Kubernetes cluster version.
246+
>
247+
> You can check the version of your Kubernetes cluster in GKE by going to https://console.cloud.google.com/kubernetes. In the list of clusters, click on the name of your cluster. In the cluster details page, under the 'Cluster basics' section, you can see the Kubernetes version for your cluster.
248+
>
249+
> For example, if your cluster's Kubernetes version is 1.24.7-..., the `kubectl` version that you install cannot be lower than 1.23.x or higher than 1.25.x. You should always install the latest version of `kubectl` that is compatible with your Kubernetes cluster, so in this case, the latest `kubectl` version that you can install is 1.25.5.
250+
251+
#### Connect `kubectl` to your Kubernetes cluster
252+
253+
To access your Kubernetes from `kubectl`, first install an authentication plugin for the `gcloud` CLI tool by running the following command:
254+
255+
```
256+
gcloud components install gke-gcloud-auth-plugin
257+
```
258+
259+
Once the plugin has been installed, connect `kubectl` to your Kubernetes cluster by running one of the following commands:
260+
261+
* If your cluster's location type was zonal, run the following command:
262+
263+
```
264+
gcloud container clusters get-credentials <cluster_name> --zone <zone_name>
265+
```
266+
267+
Replace `<cluster_name>` with the name you used for your cluster, and `<zone_name>` with the name of the zone your cluster was created in.
268+
269+
* If your cluster's location type was regional, run the following command:
270+
271+
```
272+
gcloud container clusters get-credentials <cluster_name> --region <region_name>
273+
```
274+
275+
Replace `<cluster_name>` with the name you used for your cluster, and `<region_name>` with the name of the region your cluster was created in.
276+
277+
If the above command was successful, the running the following command:
278+
279+
```
280+
kubectl get svc
281+
```
282+
283+
should output something like the following:
284+
285+
```
286+
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
287+
kubernetes ClusterIP 10.72.0.1 <none> 443/TCP 19h
288+
```
289+
290+
You Kubernetes cluster is now ready for deployments.
291+
292+
## Deploying the Helm Chart to Your Kubernetes Cluster
293+
294+
After you have created your Kubernetes cluster and set up `kubectl` to access it, deploying the WhatsApp proxy Helm chart is very simple.
295+
296+
From the root of the chart directory (`whatsapp-proxy-chart/`), run one of the following commands:
297+
298+
* If you created your Kubernetes cluster on Amazon EKS, run the following command:
299+
```
300+
helm install whatsapp-proxy . -f deployments/overrides/values.eks.yaml
301+
```
302+
* If you created your Kubernetes cluster on GKE, run the following command:
303+
```
304+
helm install whatsapp-proxy . -f deployments/overrides/values.gke.yaml
305+
```
306+
307+
The above command will install the Helm chart on your Kubernetes cluster.
308+
309+
To get the public endpoint for your deployment, run the following:
310+
311+
```
312+
kubectl get svc
313+
```
314+
315+
The output should look like the following:
316+
317+
```
318+
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
319+
kubernetes ClusterIP 10.72.0.1 <none> 443/TCP 19h
320+
whatsapp-proxy-whatsapp-proxy-chart LoadBalancer 10.72.2.240 <PUBLIC_ENDPOINT> 8080:32220/TCP,8443:32287/TCP,8222:30054/TCP,5222:32734/TCP,80:31717/TCP,443:32498/TCP,8199:30617/TCP 3s
321+
```
322+
323+
The public endpoint for your deployment will appear under EXTERNAL-IP.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Copyright (c) Meta Platforms, Inc. and affiliates.
2+
#
3+
# License found in the LICENSE file in the root directory
4+
# of this source tree.
5+
6+
# Values override for whatsapp-proxy-chart for deploying to Amazon EKS.
7+
# Note: This values override file is not part of the core project.
8+
# Rather, it is provided here as an example override file to help with
9+
# deployment to Amazon's EKS service.
10+
11+
service:
12+
type: LoadBalancer
13+
annotations:
14+
service.beta.kubernetes.io/aws-load-balancer-type: "external"
15+
service.beta.kubernetes.io/aws-load-balancer-nlb-target-type: "ip"
16+
service.beta.kubernetes.io/aws-load-balancer-scheme: "internet-facing"
17+
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Copyright (c) Meta Platforms, Inc. and affiliates.
2+
#
3+
# License found in the LICENSE file in the root directory
4+
# of this source tree.
5+
6+
# Values override for whatsapp-proxy-chart for deploying to Google Kubernetes Engine (GKE).
7+
# Note: This values override file is not part of the core project.
8+
# Rather, it is provided here as an example override file to help with
9+
# deployment to Google Kubernetes Engine.
10+
11+
service:
12+
type: LoadBalancer
13+
annotations:
14+
cloud.google.com/l4-rbs: "enabled"
15+
16+
podSecurityContext:
17+
sysctls:
18+
- name: net.ipv4.ip_unprivileged_port_start
19+
value: "0"
20+

charts/whatsapp-proxy-chart/templates/service.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ metadata:
88
name: {{ include "whatsapp-proxy-chart.fullname" . }}
99
labels:
1010
{{- include "whatsapp-proxy-chart.labels" . | nindent 4 }}
11+
{{- with .Values.service.annotations }}
12+
annotations:
13+
{{- toYaml . | nindent 4 }}
14+
{{- end }}
1115

1216
spec:
1317
type: {{ .Values.service.type }}

0 commit comments

Comments
 (0)