Skip to content

Instantly share code, notes, and snippets.

@ThijsFeryn ThijsFeryn/Dockerfile
Last active Jul 4, 2017

Embed
What would you like to do?
Dockerized Hello NodeJS example to test Kubernetes
FROM node:6.9.2
EXPOSE 8080
COPY server.js .
CMD node server.js
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: hello-nodejs
spec:
replicas: 2
template:
metadata:
labels:
app: hello-nodejs
spec:
containers:
- image: hello-nodejs:latest
imagePullPolicy: IfNotPresent
name: hello-nodejs
ports:
- containerPort: 8080
apiVersion: v1
kind: Service
metadata:
name: hello-nodejs-service
spec:
type: NodePort
ports:
- port: 8080
targetPort: 8080
protocol: TCP
selector:
app: hello-nodejs
#!/usr/bin/env bash
eval $(minikube docker-env)
docker build -t hello-nodejs .
kubectl create -f hello_nodejs_deployment.yml
kubectl create -f hello_nodejs_service.yml
curl $(minikube service hello-nodejs-service --url)
var http = require('http');
var handleRequest = function(request, response){
console.log("rx request for url:" + request.url);
response.writeHead(200)
response.end('Hello World: ' + process.env.HOSTNAME);
};
var www = http.createServer(handleRequest);
www.listen(8080);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.