mkdir hello
폴더하나 만들고 그 안에 Dockerfile
hello.js
파일을 만들어 준다.FROM node:lts-slim
ADD ./hello.js /hello.js
EXPOSE 9000
CMD node /hello.js
var http = require('http');
var content = function(req, resp) {
resp.end("Hello Kubernetes!" + "\n9000");
resp.writeHead(200);
}
var w = http.createServer(content);
w.listen(9000);
docker build --tag gugucone/hello:8000 .
docker build --tag gugucone/hello:9000 .
docker login
username이랑 password를 입력docker push gugucone/hello:8000
docker push gugucone/hello:9000
apiVersion: v1
kind: Pod
metadata:
name: hello-pod
labels:
app: hello
spec:
containers:
- name: hello-container1
image: gugucone/hello:9000
ports:
- containerPort: 9000
- name: hello-container2
image: gugucone/hello:8000
ports:
- containerPort: 8000
apiVersion: v1
kind: Service
metadata:
name: svc-1
spec:
selector:
app: hello
ports:
- port: 8000
name: "hello8000"
- port: 9000
name: "hello9000"