Dockerfile 构建镜像
三个文件
app.js
const http = require('http');
const os = require('os');
console.log("kubia server starting...");
var handler = function(request, response) {
console.log("Received request from" + request.connection.remoteAddress);
response.writeHead(200);
response.end("You've hit " + os.hostname() + "\n");
};
var www = http.createServer(handler);
www.listen(8080);
Dockerfile
FROM node:7
ADD app.js /app.js
ENTRYPOINT ["node", "app.js"]
kubia-manual.yaml
FROM node:7
ADD app.js /app.js
ENTRYPOINT ["node", "app.js"]
[root@VM-113-112-centos ~/test]# cat kubia-manual.yaml
apiVersion: v1
kind: Pod
metadata:
name: kubia-manual
spec:
containers:
- image: lalala/kubia:1.13.0
imagePullPolicy: IfNotPresent
name: kubia
resources:
limits:
cpu: 100m
memory: "500Mi"
ports:
- containerPort: 8080
protocol: TCP
构建
docker build -t lalala/kubia .
跑起来^0
docker run --name kubia -it kubia
结果出现(╯°□°)╯︵ ┻━┻:
ps: 这里是kubectl部署时候出现的错误,不过差不多,都是没有从本地拉去跑去远端找,远端肯定是没有的啦o(︶︿︶)o
k8s部署kubia
kubectl apply -f kubia-manaul.yaml
依然失败¯_(ツ)_/¯
很迷,网上也很难搜索到,行,也许是构建镜像到问题,再构建一次看看不久好了,lets try !p(_)q
重新构建镜像,贴了标签
docker build -f Dockerfile -t lalala/kubia:1.13.0 .
然后就按早原来的步骤继续,what!!!!!居然跑上了(ˉ︶ˉ)
kubectl get pod -o wide
也知道了 IP,来访问一下(o^^o)
curl 192.168.10.5:8080
哈哈哈,对不起,打了你(#^^#)
查看下日志
kubectl logs -f kubia-manual
无奈,莫名其妙的error,幸亏好了d(^ - ^o)