本篇内容主要讲解“怎么用k8s部署自己的web平台”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“怎么用k8s部署自己的web平台”吧!
1. 制作mariadb镜像,在Dockerfile中初始化数据库,源码:
https://github.com/zhanggq/mariadb
2. 制作自己的web镜像,后端用go编写,前端用的amaze,开放端口8082,源码暂不提供
3. Dashboard上点创建,粘贴yaml,启动mariadb rc
apiVersion: v1
kind: ReplicationController
metadata:
name: mysql
spec:
replicas: 1
selector:
app: mysql
template:
metadata:
labels:
app: mysql
spec:
containers:
- image: registry.cn-hangzhou.aliyuncs.com/zhanggq/mariadb:v10.1
name: mysql
resources:
limits:
cpu: "2"
memory: 2Gi
ports:
- containerPort: 3306
env:
- name: MYSQL_ROOT_PASSWORD
value: "123456"
4. 启动mariadb svc
apiVersion: v1
kind: Service
metadata:
name: mysql
spec:
ports:
- name: mysql-svc
port: 3306
targetPort: 3306
nodePort: 31101
selector:
app: mysql
type: NodePort
5. 启动amaze rc
apiVersion: v1
kind: ReplicationController
metadata:
name: amaze
spec:
replicas: 1
selector:
app: amaze
template:
metadata:
labels:
app: amaze
spec:
containers:
- image: registry.cn-hangzhou.aliyuncs.com/zhanggq/amaze:v1.0
name: amaze
resources:
limits:
cpu: "1"
memory: 1Gi
ports:
- containerPort: 8082
6. 启动amaze svc
apiVersion: v1
kind: Service
metadata:
name: amaze
spec:
ports:
- name: amaze-svc
port: 8082
targetPort: 8082
nodePort: 30082
selector:
app: amaze
type: NodePort
遇到的问题
1. docker启动容器报错:
docker: Error response from daemon: mkdir /var/lib/docker/overlay/64d4cbac6ef69d5b84fc753e83dc2849f14e43177d0e9d
a532eb61499ce7e2fc-init/merged/dev/shm: invalid argument.
解决办法:升级内核
原内核Kernel Version: 3.10.0-229.el7.x86_64
升级后内核4.6.0-1.el7.elrepo.x86_64
2. 手工改了一下web应用里面的配置,远程连接mysql数据库10.233.104.69:3306
到此,相信大家对“怎么用k8s部署自己的web平台”有了更深的了解,不妨来实际操作一番吧!这里是亿速云网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。