一、打包镜像
- 通过jenkins打包镜像并上传到镜像仓库,只选版本号,不选部署环境,默认上传仓库地址为:
hub.pml.com/sail/ac-device:${imageVersion}hub.pml.com/sail/ac-management:${imageVersion}hub.pml.com/sail/ac-monitor:${imageVersion}hub.pml.com/sail/ac-resource-pool:${imageVersion}hub.pml.com/sail/ac-ztp:${imageVersion}
- Harbor登陆查看镜像
http://172.171.15.104/harbor/projects/15/repositories
二、生成本地文件
登陆到一台装有docker环境的机器上,拉取镜像
docker pull hub.pml.com/sail/ac-device:2.0.2docker pull hub.pml.com/sail/ac-management:2.0.2docker pull hub.pml.com/sail/ac-monitor:2.0.2docker pull hub.pml.com/sail/ac-resource-pool:2.0.2docker pull hub.pml.com/sail/ac-ztp:2.0.2

通过tar文件保存到本地
docker save -o ac-device_2.0.2.tar hub.pml.com/sail/ac-device:2.0.2docker save -o ac-management_2.0.2.tar hub.pml.com/sail/ac-management:2.0.2docker save -o ac-monitor_2.0.2.tar hub.pml.com/sail/ac-monitor:2.0.2docker save -o ac-resource-pool_2.0.2.tar hub.pml.com/sail/ac-resource-pool:2.0.2docker save -o ac-ztp_2.0.2.tar hub.pml.com/sail/ac-ztp:2.0.2
三、准备yaml文件
ac-device.yaml ```yaml apiVersion: v1 kind: Service metadata: name: ac-device namespace: access-controller labels: app: ac-device spec: ports:
- port: 9901 name: service targetPort: 9901 protocol: TCP
- port: 9911 name: debug targetPort: 9911 protocol: TCP nodePort: 30101 selector: app: ac-device type: NodePort
apiVersion: apps/v1 kind: Deployment metadata: name: ac-device namespace: access-controller labels: app: ac-device spec: replicas: 1 strategy: type: Recreate selector: matchLabels: app: ac-device template: metadata: labels: app: ac-device spec: hostAliases:
- ip: 10.33.2.138hostnames:- mysql.mysql.svc.cluster.localnodeSelector:ac: node1containers:- name: ac-deviceimage: hub.pml.com/sail/ac-device:2.0.2imagePullPolicy: IfNotPresentports:- containerPort: 9901resources:limits:memory: 2Girequests:memory: 500Mienv:- name: MYSQL_PASSWORDvalue: "ZZPass2019!"- name: LIMITS_MEMORYvalueFrom:resourceFieldRef:resource: limits.memorydivisor: 1Mi- name: JAVA_OPTSvalue: "-Xmx500m -Xdebug -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=9911 -XshowSettings:vm -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote.port=12345 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.rmi.port=12345 -Djava.rmi.server.hostname=localhost -Dcom.sun.management.jmxremote.authenticate=false -Dfile.encoding=UTF8 -Ddruid.mysql.usePingMethod=false -Duser.timezone=GMT+08 -verbose:gc -XX:+PrintGCTimeStamps -XX:+PrintHeapAtGC -XX:+PrintGCDetails -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=50M -Xloggc:/var/log/jvm/gcc.log -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/var/log/jvm/ -XX:+PrintGCDateStamps"volumeMounts:- name: date-configmountPath: /etc/localtime- name: jvm-logmountPath: /var/log/jvm/- name: app-logmountPath: /opt/log/livenessProbe:httpGet:path: /ac/device/health-checkport: 9901initialDelaySeconds: 30timeoutSeconds: 3failureThreshold: 3periodSeconds: 30readinessProbe:httpGet:path: /ac/device/health-checkport: 9901initialDelaySeconds: 30timeoutSeconds: 3failureThreshold: 3periodSeconds: 30volumes:- name: date-confighostPath:path: /etc/localtime- name: jvm-loghostPath:path: /var/log/jvm/access-controller/ac-device/- name: app-loghostPath:path: /var/log/app/access-controller/ac-device/
ac-management.yaml```yamlapiVersion: v1kind: Servicemetadata:name: ac-managementnamespace: access-controllerlabels:app: ac-managementspec:ports:- port: 9902name: servicetargetPort: 9902protocol: TCP- port: 9912name: debugtargetPort: 9912protocol: TCPnodePort: 30102selector:app: ac-managementtype: NodePort---apiVersion: apps/v1kind: Deploymentmetadata:name: ac-managementnamespace: access-controllerlabels:app: ac-managementspec:replicas: 1strategy:type: Recreateselector:matchLabels:app: ac-managementtemplate:metadata:labels:app: ac-managementspec:hostAliases:- ip: 10.33.2.138hostnames:- mysql.mysql.svc.cluster.localnodeSelector:ac: node1containers:- name: ac-managementimage: hub.pml.com/sail/ac-management:2.0.2imagePullPolicy: IfNotPresentports:- containerPort: 9902resources:limits:memory: 2Girequests:memory: 500Mienv:- name: MYSQL_PASSWORDvalue: "ZZPass2019!"- name: LIMITS_MEMORYvalueFrom:resourceFieldRef:resource: limits.memorydivisor: 1Mi- name: JAVA_OPTSvalue: "-Xmx500m -Xdebug -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=9912 -XshowSettings:vm -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote.port=12345 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.rmi.port=12345 -Djava.rmi.server.hostname=localhost -Dcom.sun.management.jmxremote.authenticate=false -Dfile.encoding=UTF8 -Ddruid.mysql.usePingMethod=false -Duser.timezone=GMT+08 -verbose:gc -XX:+PrintGCTimeStamps -XX:+PrintHeapAtGC -XX:+PrintGCDetails -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=50M -Xloggc:/var/log/jvm/gcc.log -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/var/log/jvm/ -XX:+PrintGCDateStamps"volumeMounts:- name: date-configmountPath: /etc/localtime- name: jvm-logmountPath: /var/log/jvm/- name: app-logmountPath: /opt/log/livenessProbe:httpGet:path: /ac/management/health-checkport: 9902initialDelaySeconds: 30timeoutSeconds: 3failureThreshold: 3periodSeconds: 30readinessProbe:httpGet:path: /ac/management/health-checkport: 9902initialDelaySeconds: 30timeoutSeconds: 3failureThreshold: 3periodSeconds: 30volumes:- name: date-confighostPath:path: /etc/localtime- name: jvm-loghostPath:path: /var/log/jvm/access-controller/ac-management/- name: app-loghostPath:path: /var/log/app/access-controller/ac-management/
ac-monitor.yaml
apiVersion: v1kind: Servicemetadata:name: ac-monitornamespace: access-controllerlabels:app: ac-monitorspec:ports:- port: 9903name: servicetargetPort: 9903protocol: TCP- port: 9913name: debugtargetPort: 9913protocol: TCPnodePort: 30103selector:app: ac-monitortype: NodePort---apiVersion: apps/v1kind: Deploymentmetadata:name: ac-monitornamespace: access-controllerlabels:app: ac-monitorspec:replicas: 1strategy:type: Recreateselector:matchLabels:app: ac-monitortemplate:metadata:labels:app: ac-monitorspec:hostAliases:- ip: 10.33.2.138hostnames:- mysql.mysql.svc.cluster.localnodeSelector:ac: node1containers:- name: ac-monitorimage: hub.pml.com/sail/ac-monitor:2.0.2imagePullPolicy: IfNotPresentports:- containerPort: 9903resources:limits:memory: 2Girequests:memory: 500Mienv:- name: MYSQL_PASSWORDvalue: "ZZPass2019!"- name: LIMITS_MEMORYvalueFrom:resourceFieldRef:resource: limits.memorydivisor: 1Mi- name: JAVA_OPTSvalue: "-Xmx500m -Xdebug -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=9913 -XshowSettings:vm -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote.port=12345 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.rmi.port=12345 -Djava.rmi.server.hostname=localhost -Dcom.sun.management.jmxremote.authenticate=false -Dfile.encoding=UTF8 -Ddruid.mysql.usePingMethod=false -Duser.timezone=GMT+08 -verbose:gc -XX:+PrintGCTimeStamps -XX:+PrintHeapAtGC -XX:+PrintGCDetails -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=50M -Xloggc:/var/log/jvm/gcc.log -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/var/log/jvm/ -XX:+PrintGCDateStamps"volumeMounts:- name: date-configmountPath: /etc/localtime- name: jvm-logmountPath: /var/log/jvm/- name: app-logmountPath: /opt/log/livenessProbe:httpGet:path: /ac/monitor/health-checkport: 9903initialDelaySeconds: 30timeoutSeconds: 3failureThreshold: 3periodSeconds: 30readinessProbe:httpGet:path: /ac/monitor/health-checkport: 9903initialDelaySeconds: 30timeoutSeconds: 3failureThreshold: 3periodSeconds: 30volumes:- name: date-confighostPath:path: /etc/localtime- name: jvm-loghostPath:path: /var/log/jvm/access-controller/ac-monitor/- name: app-loghostPath:path: /var/log/app/access-controller/ac-monitor/
ac-resource-pool.yaml
apiVersion: v1kind: Servicemetadata:name: ac-resource-poolnamespace: access-controllerlabels:app: ac-resource-poolspec:ports:- port: 9904name: servicetargetPort: 9904protocol: TCP- port: 9914name: debugtargetPort: 9914protocol: TCPnodePort: 30104selector:app: ac-resource-pooltype: NodePort---apiVersion: apps/v1kind: Deploymentmetadata:name: ac-resource-poolnamespace: access-controllerlabels:app: ac-resource-poolspec:replicas: 1strategy:type: Recreateselector:matchLabels:app: ac-resource-pooltemplate:metadata:labels:app: ac-resource-poolspec:hostAliases:- ip: 10.33.2.138hostnames:- mysql.mysql.svc.cluster.localnodeSelector:ac: node1containers:- name: ac-resource-poolimage: hub.pml.com/sail/ac-resource-pool:2.0.2imagePullPolicy: IfNotPresentports:- containerPort: 9904resources:limits:memory: 2Girequests:memory: 500Mienv:- name: MYSQL_PASSWORDvalue: "ZZPass2019!"- name: LIMITS_MEMORYvalueFrom:resourceFieldRef:resource: limits.memorydivisor: 1Mi- name: JAVA_OPTSvalue: "-Xmx500m -Xdebug -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=9914 -XshowSettings:vm -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote.port=12345 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.rmi.port=12345 -Djava.rmi.server.hostname=localhost -Dcom.sun.management.jmxremote.authenticate=false -Dfile.encoding=UTF8 -Ddruid.mysql.usePingMethod=false -Duser.timezone=GMT+08 -verbose:gc -XX:+PrintGCTimeStamps -XX:+PrintHeapAtGC -XX:+PrintGCDetails -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=50M -Xloggc:/var/log/jvm/gcc.log -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/var/log/jvm/ -XX:+PrintGCDateStamps"volumeMounts:- name: date-configmountPath: /etc/localtime- name: jvm-logmountPath: /var/log/jvm/- name: app-logmountPath: /opt/log/livenessProbe:httpGet:path: /ac/resource/health-checkport: 9904initialDelaySeconds: 30timeoutSeconds: 3failureThreshold: 3periodSeconds: 30readinessProbe:httpGet:path: /ac/resource/health-checkport: 9904initialDelaySeconds: 30timeoutSeconds: 3failureThreshold: 3periodSeconds: 30volumes:- name: date-confighostPath:path: /etc/localtime- name: jvm-loghostPath:path: /var/log/jvm/access-controller/ac-resource-pool/- name: app-loghostPath:path: /var/log/app/access-controller/ac-resource-pool/
ac-ztp.yaml
apiVersion: v1kind: Servicemetadata:name: ac-ztpnamespace: access-controllerlabels:app: ac-ztpspec:ports:- port: 9905name: servicetargetPort: 9905protocol: TCP- port: 9915name: debugtargetPort: 9915protocol: TCPnodePort: 30105selector:app: ac-ztptype: NodePort---apiVersion: apps/v1kind: Deploymentmetadata:name: ac-ztpnamespace: access-controllerlabels:app: ac-ztpspec:replicas: 1strategy:type: Recreateselector:matchLabels:app: ac-ztptemplate:metadata:labels:app: ac-ztpspec:hostAliases:- ip: 10.33.2.138hostnames:- mysql.mysql.svc.cluster.localnodeSelector:ac: node1containers:- name: ac-ztpimage: hub.pml.com/sail/ac-ztp:2.0.2imagePullPolicy: IfNotPresentports:- containerPort: 9905resources:limits:memory: 2Girequests:memory: 500Mienv:- name: MYSQL_PASSWORDvalue: "ZZPass2019!"- name: LIMITS_MEMORYvalueFrom:resourceFieldRef:resource: limits.memorydivisor: 1Mi- name: JAVA_OPTSvalue: "-Xmx500m -Xdebug -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=9915 -XshowSettings:vm -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote.port=12345 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.rmi.port=12345 -Djava.rmi.server.hostname=localhost -Dcom.sun.management.jmxremote.authenticate=false -Dfile.encoding=UTF8 -Ddruid.mysql.usePingMethod=false -Duser.timezone=GMT+08 -verbose:gc -XX:+PrintGCTimeStamps -XX:+PrintHeapAtGC -XX:+PrintGCDetails -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=50M -Xloggc:/var/log/jvm/gcc.log -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/var/log/jvm/ -XX:+PrintGCDateStamps"volumeMounts:- name: date-configmountPath: /etc/localtime- name: jvm-logmountPath: /var/log/jvm/- name: app-logmountPath: /opt/log/livenessProbe:httpGet:path: /ac/ztp/health-checkport: 9905initialDelaySeconds: 30timeoutSeconds: 3failureThreshold: 3periodSeconds: 30readinessProbe:httpGet:path: /ac/ztp/health-checkport: 9905initialDelaySeconds: 30timeoutSeconds: 3failureThreshold: 3periodSeconds: 30volumes:- name: date-confighostPath:path: /etc/localtime- name: jvm-loghostPath:path: /var/log/jvm/access-controller/ac-ztp/- name: app-loghostPath:path: /var/log/app/access-controller/ac-ztp/
ac-gateway.yaml
apiVersion: networking.istio.io/v1alpha3kind: Gatewaymetadata:name: ac-gatewaynamespace: access-controllerspec:selector:istio: ingressgatewayservers:- port:number: 9900name: httpprotocol: HTTPhosts:- "*"---apiVersion: networking.istio.io/v1alpha3kind: VirtualServicemetadata:name: ac-gatewaynamespace: access-controllerspec:hosts:- "*"gateways:- ac-gatewayhttp:- match:- uri:prefix: /ac/deviceroute:- destination:port:number: 9901host: ac-device- match:- uri:prefix: /ac/managementroute:- destination:port:number: 9902host: ac-management- match:- uri:prefix: /ac/monitorroute:- destination:port:number: 9903host: ac-monitor- match:- uri:prefix: /ac/resourceroute:- destination:port:number: 9904host: ac-resource-pool- match:- uri:prefix: /ac/ztproute:- destination:port:number: 9905host: ac-ztp
ac-ingressgateway.yaml
apiVersion: v1kind: Servicemetadata:labels:app: istio-ingressgatewayistio: ingressgatewayoperator.istio.io/component: IngressGatewaysoperator.istio.io/managed: Reconcilerelease: istioname: ac-ingressgatewaynamespace: istio-systemspec:externalTrafficPolicy: Clusterports:- name: access-controller-public-portnodePort: 30100port: 9900protocol: TCPtargetPort: 9900selector:app: istio-ingressgatewayistio: ingressgatewaysessionAffinity: Nonetype: LoadBalancer
namespace.yaml
apiVersion: v1kind: Namespacemetadata:name: access-controllerlabels:istio-injection: enabled
四、文件移到生产环境
打包文件
tar -zcvf cnos-ac.tar.gz ac/

远程拷贝文件,密码为cdn%nf
scp cnos-ac.tar.gz root@58.240.113.50:/home/2.0.2
目的机器解压文件
tar -zxvf cnos-ac.tar.gz
五、安装服务
上传到本地镜像仓库
docker load -i ac-device_2.0.2.tardocker load -i ac-management_2.0.2.tadocker load -i ac-monitor_2.0.2.tardocker load -i ac-resource-pool_2.0.2.tardocker load -i ac-ztp_2.0.2.tar

通过kubectl安装服务
kubectl apply -f namespace.yamlkubectl apply -f ac-gateway.yamlkubectl apply -f ac-ingressgateway.yamlkubectl apply -f ac-device.yamlkubectl apply -f ac-management.yamlkubectl apply -f ac-monitor.yamlkubectl apply -f ac-resource-pool.yamlkubectl apply -f ac-ztp.yaml
查看服务运行状态

