Build localstack on local k8s cluster - updated
Localstack on local k8s cluster - updated
Installation with yaml file
Set up your Kubernetes cluster:
- Install a Kubernetes cluster locally. Follow the respective documentation for installation instructions.
Deploy localStack and localstack web dashboard to your Kubernetes cluster:
Create a Kubernetes deployment YAML file, for example,
localstack-deployment.yamlwith the following contents:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105apiVersion: v1
kind: Namespace
metadata:
name: localstack
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: localstack
namespace: localstack
spec:
replicas: 1
selector:
matchLabels:
app: localstack
template:
metadata:
labels:
app: localstack
spec:
containers:
- name: localstack
image: localstack/localstack
ports:
- containerPort: 4566
env:
- name: SERVICES
value: "*"
resources:
limits:
cpu: 1
memory: 1Gi
requests:
cpu: 500m
memory: 500Mi
---
apiVersion: v1
kind: Service
metadata:
name: localstack
namespace: localstack
spec:
selector:
app: localstack
ports:
- name: localstack-port
protocol: TCP
port: 4566
targetPort: 4566
type: NodePort
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: localstack-web
namespace: localstack
spec:
replicas: 1
selector:
matchLabels:
app: localstack-web
template:
metadata:
labels:
app: localstack-web
spec:
containers:
- name: localstack-web
image: localstack/localstack-web
ports:
- containerPort: 8080
env:
- name: SERVICES
value: "*"
resources:
limits:
cpu: 500m
memory: 500Mi
requests:
cpu: 250m
memory: 250Mi
---
apiVersion: v1
kind: Service
metadata:
name: localstack-web
namespace: localstack
spec:
selector:
app: localstack-web
ports:
- name: localstack-web-port
protocol: TCP
port: 8080
targetPort: 8080
type: NodePortApply the deployment to your Kubernetes cluster:
kubectl apply -f localstack-deployment.yaml.
Access LocalStack services:
With the LocalStack deployment described in the
localstack-deployment.yamlfile, you can determine the AWS endpoints for each service by using the following steps:Find the NodePort assigned to the
localstackservice:Run the following command to get the NodePort value:
1
kubectl get service -n localstack localstack -o jsonpath='{.spec.ports[0].nodePort}'Note down the NodePort value returned by the command.
Determine the IP address of your Kubernetes cluster:
Run the following command to get the IP address of your cluster:
1
kubectl cluster-info | grep 'Kubernetes master' | awk '/http/ {print $NF}' | sed -e 's/.*\/\///'Note down the IP address returned by the command.
Build the AWS service endpoint URLs:
Combine the IP address and NodePort value obtained in the previous steps to construct the AWS service endpoints:
For LocalStack services, the endpoint URL format is:
1
http://<Cluster-IP>:<NodePort>Replace
<Cluster-IP>with the IP address of your Kubernetes cluster, and<NodePort>with the NodePort value from step 1.For each AWS service, the endpoint URL format is:
1
http://<Cluster-IP>:<NodePort>/<Service-Name>Replace
<Cluster-IP>with the IP address of your Kubernetes cluster,<NodePort>with the NodePort value from step 1, and<Service-Name>with the name of the AWS service (e.g., s3, sqs, lambda).
For example, if your cluster’s IP address is
192.168.1.100and the NodePort assigned to thelocalstackservice is30000, here are a few examples of AWS service endpoint URLs:- S3:
http://192.168.1.100:30000/s3 - SQS:
http://192.168.1.100:30000/sqs - Lambda:
http://192.168.1.100:30000/lambda
Installation with helm3
Follow the guide here: https://docs.localstack.cloud/getting-started/installation/
1 | |
1 | |