Docker, terraform, go installed in your local.
cd terraform/kind
terraform init
terraform apply
cd ../..
Nginx Ingress Controller install:
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/deploy/static/provider/kind/deploy.yaml
Please wait until it is created.
Have to say that easiest way to create it is directly in k8s with yaml, but Prima team considered is not IaC.
Point out that this:
- will create the k8s namespace "prima"
- the mysql server, you can see that the terraform module mysql initializes as well the database with contents.
- for simlicity I have disabled authentication to access the RDS, this can be done through k8s Secrets, using aws-external-secret controller for AWS,...
- For simplicity I have just added one env var to the API, "DBHOST"
cd terraform/mysql
terraform init
terraform apply
cd ../..
This will create the binary for linux amd64, then the docker container and will push it to kind.
make binary
make build
kubectl apply -f ./k8s/api/ -n prima
Get all users from mysql:
curl http://localhost/users
This will output:
[{"id":"1","name":"Joan Porta"},{"id":"2","name":"John McEnroe"}]
Add a user to mysql:
curl -d '{"id":"3","name":"Eva Cano"}' -H "Content-Type: application/json" -X POST http://localhost/user
This will output:
[{"id":"1","name":"Joan Porta"},{"id":"2","name":"John McEnroe"},{"id":"3","name":"Eva Cano"}]