Skip to content

Instantly share code, notes, and snippets.

@mcharo
Last active April 15, 2019 02:21
Show Gist options
  • Select an option

  • Save mcharo/dcfad59ab6d601fb3d69e9ff134a40be to your computer and use it in GitHub Desktop.

Select an option

Save mcharo/dcfad59ab6d601fb3d69e9ff134a40be to your computer and use it in GitHub Desktop.
minikube tests
# create hello-node deployment
kubectl create deployment hello-node --image=gcr.io/hello-minikube-zero-install/hello-node
# create loadbalancer service to expose hello-node pods on external network
kubectl expose deployment hello-node --type=LoadBalancer --port=8080
# open browser to service
minikube service hello-node
# scale number of pods behind service to 3
kubectl scale --replicas=3 deployments/hello-node
# modify server.js to print pod name
cat <<EOF ./server.js
var http = require('http');
var os = require('os');
var handleRequest = function(request, response) {
console.log('Received request for URL: ' + request.url);
response.writeHead(200);
response.end(os.hostname());
};
var www = http.createServer(handleRequest);
www.listen(8080);
EOF
# create dockerfile
cat <<EOF >./dockerfile
FROM gcr.io/hello-minikube-zero-install/hello-node
COPY server.js /
RUN /bin/sh -c node server.js
EOF
# build image from dockerfile
docker build --tag=smcharo/hello-node .
# push image to docker hub
docker push smcharo/hello-node
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment