k8s部署本身的web平臺

1. 製做mariadb鏡像,在Dockerfile中初始化數據庫,源碼:前端

https://github.com/zhanggq/mariadbnode

 

2. 製做本身的web鏡像,後端用go編寫,前端用的amaze,開放端口8082,源碼暫不提供mysql

 

3. Dashboard上點建立,粘貼yaml,啓動mariadb rcgit

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"github

4. 啓動mariadb svcweb

apiVersion: v1
kind: Service
metadata:
  name: mysql
spec:
  ports:
  - name: mysql-svc
    port: 3306
    targetPort: 3306
    nodePort: 31101
  selector:
    app: mysql
  type: NodePortsql

 

5. 啓動amaze rcdocker

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

後來發現實際上是沒搞清楚Kubernetes中Service的概念。具體的分析在下文介紹。

相關文章
相關標籤/搜索