k8s实战--edusoho平台创建

k8s实战--edusoho平台创建

  1. 基本信息说明
    使用kubeadm方式安装kubernetes
    Kubernetes集群添加/删除Node
    Kubernetes Dashboard1.8.3部署
    k8s原生的集群监控方案(Heapster+InfluxDB+Grafana)
  2. 项目地址
    k8s-edusoho平台创建
  3. 镜像下载
    如上面的项目地址无法使用,请使用下面链接下载相应镜像
    docker pull wutengfei/lnmp-nginx (构建LNMP平台镜像--nginx,nginx版本:nginx/1.13.0)
    docker pull wutengfei/lnmp-php (构建LNMP平台基础镜像php,php的版本:PHP 7.1.5)
    docker pull wutengfei/mysql (构建LNMP平台的基础镜像--mysql,mysql版本是:mysql:5.6)
  4. 项目文件结构和YAML文件
    (1)项目文件结构
    # pwd
    /data
    # tree -L 3
    .
    ├── mysql
    │   ├── conf
    │   │   └── my.cnf
    │   └── data
    ├── nginx
    │   ├── conf
    │   │   └── nginx.conf
    │   ├── edusoho
    │   │   ├── api
    │   │   ├── app
    │   │   ├── bootstrap
    │   │   ├── plugins
    │   │   ├── src
    │   │   ├── vendor
    │   │   ├── vendor_user
    │   │   └── web
    │   └── log
    │       └── error.log
    ├── php
    │   ├── log
    │   │   └── php-fpm.log
    │   ├── php-fpm.conf
    │   ├── php.ini
    │   └── www.conf

(2)Pod的yaml文件

apiVersion: v1
kind: Pod
metadata:
  name: lamp-edusoho
  labels:
    app: lamp-edusoho
restartPolicy: Always
spec:
  containers:
  - name: nginx
    abels:
      app: lamp-nginx
    image: dockerhub.datagrand.com/global/nginx:v1
    ports:
    - containerPort: 80
    volumeMounts:
      - name: datadir
        mountPath: "/var/log/nginx/error.log"
        subPath: ./nginx/log/error.log
      - name: datadir
        mountPath: "/etc/nginx/nginx.conf"
        subPath: ./nginx/conf/nginx.conf
      - name: datadir
        mountPath: "/usr/share/nginx/html"
        subPath: ./nginx/edusoho
  - name: php
    image: dockerhub.datagrand.com/global/php:v1
    ports:
    - containerPort: 9000
    volumeMounts:
      - mountPath: /usr/local/php/etc/php-fpm.conf
        name: datadir
        subPath: ./php/php-fpm.conf
      - mountPath: /usr/local/php/etc/php-fpm.d/www.conf
        name: datadir
        subPath: ./php/www.conf
      - mountPath: /usr/local/php/etc/php.ini
        name: datadir
        subPath: ./php/php.ini
      - mountPath: /usr/local/php/var/log/php-fpm.log
        name: datadir
        subPath: ./php/log/php-fpm.log
      - mountPath: /usr/share/nginx/html
        name: datadir
        subPath: ./nginx/edusoho
  - name: mysql
    image: dockerhub.datagrand.com/global/mysql:5.6
    ports:
    - containerPort: 3306
    env:
      - name: MYSQL_ROOT_PASSWORD
        value: "123456"
      - name: MYSQL_DATABASE
        value: "edusoho"
      - name: MYSQL_USER
        value: "edusoho"
      - name: MYSQL_PASSWORD
        value: "edusoho"
    args: ['--character-set-server=utf8']
    volumeMounts:
      - name: datadir
        mountPath: "/var/lib/mysql"
        subPath: ./mysql/data
      - name: datadir
        mountPath: "/etc/my.cnf"
        subPath: ./mysql/conf/my.cnf
  volumes:
  - name: datadir
    persistentVolumeClaim:
      claimName: nfs-pvc

(3)PV的yaml文件

apiVersion: v1
kind: PersistentVolume
metadata:
  name: nfs-pv
spec:
  capacity:
    storage: 4Gi
  accessModes:
    - ReadWriteMany
  nfs:
    server: 192.168.246.168  ##NFS服务器的ip地址
    path: "/data"  ##NFS服务器上的共享目录

(4)PVC的yaml文件

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: nfs-pvc
spec:
  accessModes:
    - ReadWriteMany
  storageClassName: ""
  resources:
    requests:
      storage: 3Gi

(5)Service的yaml文件

apiVersion: v1
kind: Service
metadata:
  name: edusoho
  labels:
    app: edusoho
spec:
  type: NodePort 
  ports:
  - port: 80
    nodePort: 32756
  selector:
    app: lamp-edusoho

(6)使用命令汇总

查看Pod
kubectl get po -o wide
查看Service
kubectl get svc
进入容器内部某个应用,如这里的nginx
kubectl exec -it lamp-edusoho -c nginx /bin/bash

(7)访问安装Edusoho平台

http://192.168.246.168:32756/install/start-install.php
说明:这里的192.168.246.168是kubernetes的node节点IP,32756是Service中定义的nodePort。
相关文章
相关标签/搜索