准备条件

  • 部署完成kubernetes集群
  • 部署完成mysql数据库服务器
  • 部署完成consul服务器
  • 部署完成redes服务器
  • 部署完成nfs服务器

设置mysql访问

cat > mysql-service-endpoint.yaml <<EOF
apiVersion: v1
kind: Endpoints
metadata:
  name: mysql
  namespace: myapps
subsets:
  - addresses:
    - ip: 192.168.88.213
    ports:
      - port: 3307

---

apiVersion: v1
kind: Service
metadata:
  name: mysql
  namespace: myapps
spec:
  ports:
    - port: 3307
EOF

在Docker中Build需要安装的MyApps镜像

每个Node上都需要完成以下动作

  • Designer镜像 ```

    生成Dockerfile

    cat > Dockerfile.designer <<EOF

    Docker image for springboot file run

    VERSION 0.0.1

    myApps 设计时

    FROM java:8 MAINTAINER Jarod Zhou jarod@teemlink.com

    VOLUME 指定了临时文件目录为/tmp。

    其效果是在主机 /var/lib/docker 目录下创建了一个临时文件,并链接到容器的/tmp

    VOLUME /tmp

    将jar包添加到容器中并更名为app.jar

    COPY obpm-designer-consul*.jar app.jar

    定义默认存储

    VOLUME /storage

    运行jar包

定义环境变量

ENV datasource_url

ENV datasource_password

RUN bash -c 'touch /app.jar' EXPOSE 8082 ENTRYPOINT ["java","-server","-Xms256M","-Xmx512M","-jar","/app.jar","--myapps.storage.root=/storage"] CMD ["--spring.datasource.url=${datasource_url}", "--spring.datasource.password=${datasource_password}"]

EOF

手工拷贝 obpm-designer-consul-XXXX.jar到当前目录

编译镜像

docker build -t obpm-designer-consul -f ./Dockerfile.designer .


* Gateway网关镜像

生成Dockerfile

cat > Dockerfile.gateway <<EOF

Docker image for springboot file run

VERSION 0.0.1

myApps 网关gateway

FROM java:8 MAINTAINER Jarod Zhou jarod@teemlink.com

VOLUME 指定了临时文件目录为/tmp。

其效果是在主机 /var/lib/docker 目录下创建了一个临时文件,并链接到容器的/tmp

VOLUME /tmp

将jar包添加到容器中并更名为app.jar

COPY obpm-gateway*.jar app.jar

定义默认存储

VOLUME /storage

运行jar包

定义环境变量

ENV datasource_url

ENV datasource_password

RUN bash -c 'touch /app.jar' EXPOSE 8010 ENTRYPOINT ["java","-server","-Xms128M","-Xmx256M","-jar","/app.jar"]

EOF

手工拷贝 obpm-gateway*.jar-XXXX.jar到当前目录

编译镜像

docker build -t obpm-gateway-consul:v4.4sp1 -f ./Dockerfile.gateway .


* 运行时runtime镜像

cat > Dockerfile.runtime <<EOF

Docker image for springboot file run

VERSION 0.0.1

myApps 运行时

FROM java:8 MAINTAINER Jarod Zhou jarod@teemlink.com

VOLUME 指定了临时文件目录为/tmp。

其效果是在主机 /var/lib/docker 目录下创建了一个临时文件,并链接到容器的/tmp

VOLUME /tmp

将jar包添加到容器中并更名为app.jar

COPY obpm-runtime-consul*.jar app.jar

ADD obpm-runtime-consul-4.4.0.stable.jar app.jar

定义默认存储

VOLUME /storage

运行jar包

定义环境变量

ENV datasource_url

ENV datasource_password

RUN bash -c 'touch /app.jar' EXPOSE 8083 ENTRYPOINT ["java","-server","-Xms256M","-Xmx512M","-jar","/app.jar","--myapps.storage.root=/storage"] CMD ["--spring.datasource.url=${datasource_url}", "--spring.datasource.password=${datasource_password}"]

EOF docker build -t obpm-runtime-consul:v4.4sp1 -f ./Dockerfile.runtime .


* 登录器signon镜像

生成Dockerfile

cat > Dockerfile.signon <<EOF

Docker image for springboot file run

VERSION 0.0.1

myApps 统一登录

FROM java:8 MAINTAINER Jarod Zhou jarod@teemlink.com

VOLUME 指定了临时文件目录为/tmp。

其效果是在主机 /var/lib/docker 目录下创建了一个临时文件,并链接到容器的/tmp

VOLUME /tmp

将jar包添加到容器中并更名为app.jar

COPY obpm-signon*.jar app.jar

定义默认存储

VOLUME /storage

运行jar包

定义环境变量

ENV datasource_url

ENV datasource_password

RUN bash -c 'touch /app.jar' EXPOSE 8010 ENTRYPOINT ["java","-server","-Xms256M","-Xmx512M","-jar","/app.jar"]

EOF

手工拷贝 obpm-signon-consul-XXXX.jar到当前目录

编译镜像

docker build -t obpm-signon-consul:v4.4sp1 -f ./Dockerfile.signon .


**为了正常使用NFS,所有Node都需要安装yum install nfs-utils**

# namespace 和 pv 、pvc文件

kubectl delete -f myapps-ns-pv-pvc.yaml cat > myapps-ns-pv-pvc.yaml <<EOF

apiVersion: v1 kind: Namespace metadata: name: myapps


apiVersion: v1 kind: PersistentVolume metadata: name: myapps-pv-volume namespace: myapps labels: type: nfs spec: storageClassName: manual capacity: storage: 20Gi accessModes:

- ReadWriteMany

nfs: path: /application/workspace

server: 192.168.88.213

apiVersion: v1 kind: PersistentVolumeClaim metadata: name: myapps-pv-claim namespace: myapps spec: storageClassName: manual accessModes:

- ReadWriteMany

resources: requests: storage: 20Gi EOF

kubectl apply -f myapps-ns-pv-pvc.yaml


# obpm-runtime部署文件

kubectl delete -f obpm-runtime-svc-cfb-deploy.yaml

cat > obpm-runtime-svc-cfg-deploy.yaml <<EOF

kind: Service apiVersion: v1 metadata: labels: k8s-app: myapps name: obpm-runtime namespace: myapps spec: ports:

- port: 8083
  targetPort: 8083

selector: k8s-app: obpm-runtime


kind: ConfigMap apiVersion: v1 metadata: labels: k8s-app: obpm-runtime name: obpm-runtime-settings namespace: myapps


kind: Deployment apiVersion: apps/v1 metadata: labels: k8s-app: obpm-runtime name: obpm-runtime namespace: myapps spec: replicas: 1 revisionHistoryLimit: 10 selector: matchLabels: k8s-app: obpm-runtime template: metadata: labels: k8s-app: obpm-runtime spec: containers:

    - name: obpm-runtime
      image: obpm-runtime-consul:v4.4sp1

command: [ "/bin/bash", "-ce", "tail -f /dev/null" ]

      imagePullPolicy: Never
      env:
      - name: myapps.storage.root
        value: /storage
      - name: spring.datasource.url
        value: jdbc:mysql://192.168.88.213:3307/obpm2?characterEncoding=UTF-8&serverTimezone=GMT
      - name: spring.datasource.password
        value: "123456"
      - name: spring.redis.host
        value: 192.168.88.213
      - name: spring.cloud.consul.host
        value: hashicorp-consul-server.default
      ports:
        - containerPort: 8083
          protocol: TCP
      volumeMounts:
      - name: myapps-persistent-storage
        mountPath: /storage
  volumes:
  - name: myapps-persistent-storage
    persistentVolumeClaim:
      claimName: myapps-pv-claim

EOF kubectl apply -f obpm-runtime-svc-cfg-deploy.yaml


# obpm-gateway部署

kubectl delete -f obpm-gateway-svc-cfg-deploy.yaml

cat > obpm-gateway-svc-cfg-deploy.yaml <<EOF

kind: Service apiVersion: v1 metadata: labels: k8s-app: obpm-gateway name: obpm-gateway namespace: myapps spec: type: NodePort ports:

- port: 8080
  targetPort: 8080
  nodePort: 38080
  protocol: TCP

selector:

k8s-app: obpm-gateway

kind: ConfigMap apiVersion: v1 metadata: labels: k8s-app: obpm-gateway name: obpm-gateway-settings namespace: myapps


kind: Deployment apiVersion: apps/v1 metadata: labels: k8s-app: obpm-gateway name: obpm-gateway namespace: myapps spec: replicas: 1 revisionHistoryLimit: 10 selector: matchLabels: k8s-app: obpm-gateway template: metadata: labels: k8s-app: obpm-gateway spec: containers:

    - name: obpm-gateway
      image: obpm-gateway-consul:v4.4sp1

command: [ "/bin/bash", "-ce", "tail -f /dev/null" ]

      imagePullPolicy: Never
      env:
      - name: spring.cloud.consul.host
        value: hashicorp-consul-server.default
  volumes:
  - name: myapps-persistent-storage
    persistentVolumeClaim:
      claimName: myapps-pv-claim

EOF kubectl apply -f obpm-gateway-svc-cfg-deploy.yaml


# obpm-signon部署

kubectl delete -f obpm-signon-svc-cfb-deploy.yaml

cat > obpm-signon-svc-cfg-deploy.yaml <<EOF

kind: Service apiVersion: v1 metadata: labels: k8s-app: myapps name: obpm-signon namespace: myapps spec: ports:

- port: 8083
  targetPort: 8083

selector: k8s-app: obpm-signon


kind: ConfigMap apiVersion: v1 metadata: labels: k8s-app: obpm-signon name: obpm-signon-settings namespace: myapps


kind: Deployment apiVersion: apps/v1 metadata: labels: k8s-app: obpm-signon name: obpm-signon namespace: myapps spec: replicas: 1 revisionHistoryLimit: 10 selector: matchLabels: k8s-app: obpm-signon template: metadata: labels: k8s-app: obpm-signon spec: containers:

    - name: obpm-signon
      image: obpm-signon-consul:v4.4sp1

command: [ "/bin/bash", "-ce", "tail -f /dev/null" ]

      imagePullPolicy: Never
      env:
      - name: myapps.storage.root
        value: /storage
      - name: spring.datasource.url
        value: jdbc:mysql://192.168.88.213:3307/obpm2?characterEncoding=UTF-8&serverTimezone=GMT
      - name: spring.datasource.password
        value: "123456"
      - name: spring.redis.host
        value: 192.168.88.213
      - name: spring.cloud.consul.host
        value: hashicorp-consul-server.default
      ports:
        - containerPort: 8010
          protocol: TCP
      volumeMounts:
      - name: myapps-persistent-storage
        mountPath: /storage
  volumes:
  - name: myapps-persistent-storage
    persistentVolumeClaim:
      claimName: myapps-pv-claim

EOF kubectl apply -f obpm-signon-svc-cfg-deploy.yaml

```

results matching ""

    No results matching ""