- Docker
- Oldest option from K8s emulators
- Can specify kubernetes version
- Runs as Docker or some VirtualBox
- There are a bunch of addons available. For instance, cert-manager, nginx-controller...
- Runs images from localhost
brew install minikube
minikube start --driver=docker --memory 8196 --cpus=4 --kubernetes-version=v1.18.0
minikube delete
This is an example of pulling and running in the minikube cluster a nginx
image:
minikube start --driver=docker --memory 8196 --cpus=4 --kubernetes-version=v1.18.0
eval $(minikube docker-env)
docker ps
docker pull nginx
docker tag nginx test-nginx:1.0
kubectl run --image=test-nginx:1.0 nginx-app --port=80 --image-pull-policy=Never
kubectl port-forward po/nginx-app 8080:80
- Specify imagePullPolicy: IfNotPresent or imagePullPolicy: Never on your container(s).
- K8s cluster into Docker containers
- Faster startup than Minikube
- Better documentation than Minikube
- Runs images from localhost (previous load image as K3d)
- Cluster setup as code
brew install kind
kind create cluster --config=kind/cluster-conf.yaml
kind delete cluster
This is an example of pulling and running in the Kind cluster a nginx
image:
docker pull nginx:latest
docker tag nginx:latest localhost-nginx:1.0
kind load localhost-nginx:1.0
kubectl run --image=localhost-nginx:1.0 localhost-nginx --port=80 --image-pull-policy=Never
kubectl get po
kubectl logs -f
- Specify imagePullPolicy: IfNotPresent or imagePullPolicy: Never on your container(s).
- Lightweight k3s image from Docker
- Runs on Docker
- Runs faster than anyone
- More than enough to gain knowledge in k8s
- Runs images from localhost (previous load image as Kind)
- https://github.com/iwilltry42/k3d-demo
brew install k3d
k3d cluster create mycluster
k3d cluster delete mycluster
This is an example of pulling and running in the K3d cluster a nginx
image:
docker pull nginx:latest
docker tag nginx:latest localhost-nginx:1.0
k3d image import localhost-nginx:1.0 -c mycluster
kubectl run --image=localhost-nginx:1.0 localhost-nginx --port=80 --image-pull-policy=Never
- Specify imagePullPolicy: IfNotPresent or imagePullPolicy: Never on your container(s).
For those interested in try their services before going to AWS, they can deploy localstack in Minikube and create their AWS resources in localhost
The steps to deploy localstack in your Minikube are the following:
K8s yaml definition details
image: localstack/localstack
To be able to access from k8s:
kubectl expose pod localstack --type=ClusterIP --name=localstack
If you want to access localstack from your localhost:
kubectl port-forward po/localstack 4566:4566
Now, you can access your localstack pod. For instance, you can create a bucket:
- From localhost:
aws --endpoint-url=http://localhost:4566 s3api list-buckets
aws --endpoint-url=http://localhost:4566 s3api create-bucket --bucket test-localstack
aws --endpoint-url=http://localhost:4566 s3 cp test.sh s3://test-localstack
aws --endpoint-url=http://localhost:4566 s3 ls s3://test-localstack
- From k8s:
aws --endpoint-url=http://localstack:4566 s3api list-buckets
aws --endpoint-url=http://localstack:4566 s3api create-bucket --bucket test-localstack
aws --endpoint-url=http://localstack:4566 s3 cp test.sh s3://test-localstack
aws --endpoint-url=http://localstack:4566 s3 ls s3://test-localstack
For those supporters of Helm, there are a Helm chart in this repo to deploy with the serverless services (iam, lambda, dynamodb, apigateway, s3, sns). More settings: https://github.com/localstack/localstack#configurations
cd localstack
helm install localstack . -f values.yaml
Happy Localstacking!
Official Localstack documentation: https://github.com/localstack/localstack
helm install localstack -f ./../values.yaml
Golang code to test receive message in a Localstack SQS
aws --endpoint-url=http://localstack.localhost sqs list-queues
aws --endpoint-url=http://localstack.localhost sqs create-queue --queue-name MyQueue
aws --endpoint-url=http://localstack.localhost sqs send-message --queue-url http://localstack.localhost/000000000000/MyQueue --message-body "Information about the largest city in Any Region."
go run main.go -q="MyQueue"
GCP offers emulator for the following GCP services:
- BigTable
- Datastore
- Firestore
- PubSub
- Spanner
GCP offers PubSub emulator. A Helm chart has been setup to deploy it.
K8s yaml definition details
image: google/cloud-sdk:latest
command: ["gcloud", "beta", "emulators", "pubsub", "start", "--host-port=0.0.0.0:8085", "--project=test"]
helm install gcp-emulator . -f values.yaml
cd gcp-emulator/samples/pubsub
go test -v .