Test Live Platform: https://keyvaluestore.k8s.shubhamtatvamasi.com
Build docker image locally:
docker build -t shubhamtatvamasi/gin-key-value-store .
Run using docker:
docker run --rm -it -p 80:80 shubhamtatvamasi/gin-key-value-store
Run unit tests:
docker run --rm -it shubhamtatvamasi/gin-key-value-store go test
create a deployment and service:
kubectl create deployment gin-key-value-store --image=shubhamtatvamasi/gin-key-value-store
kubectl expose deployment gin-key-value-store --port=80 --name=gin-key-value-store
Ingress value for gin-key-value-store
kubectl apply -f - << EOF
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: gin-key-value-store
annotations:
cert-manager.io/cluster-issuer: letsencrypt
spec:
tls:
- hosts:
- keyvaluestore.k8s.shubhamtatvamasi.com
secretName: gin-key-value-store-tls
rules:
- host: keyvaluestore.k8s.shubhamtatvamasi.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: gin-key-value-store
port:
number: 80
EOF
kubectl delete deploy/gin-key-value-store svc/gin-key-value-store ing/gin-key-value-store
Deploy on Kubernetes:
kubectl run gin-key-value-store --port=80 --expose \
--image=shubhamtatvamasi/gin-key-value-store:0.3.2
kubectl patch svc gin-key-value-store \
--patch='{"spec": {"type": "NodePort"}}'
kubectl patch svc gin-key-value-store \
--patch='{"spec": {"ports": [{"nodePort": 30000, "port": 80}]}}'
Update the container image on pod:
kubectl set image po gin-key-value-store \
gin-key-value-store=shubhamtatvamasi/gin-key-value-store:0.3.2
Delete deployment:
kubectl delete po/gin-key-value-store svc/gin-key-value-store
Set key value pair:
curl -X POST -d "key=name&value=shubham" localhost/post
# Test on live server
curl -X POST -d "key=name&value=shubham" http://k8s.shubhamtatvamasi.com:30000/post
Get value from key store:
curl "localhost/get?key=name"
# Test on live server
curl "http://k8s.shubhamtatvamasi.com:30000/get?key=name"
Subscribe for a key:
curl -X POST -d "key=name" localhost/subscribe
# Test on live server
curl -X POST -d "key=name" http://k8s.shubhamtatvamasi.com:30000/subscribe