【K8S运维知识汇总】第6天5: 交付Apollo-portal至k8s集群

网友投稿 361 2022-09-07

【K8S运维知识汇总】第6天5: 交付Apollo-portal至k8s集群

文章目录

​​下载安装包​​​​执行数据库脚本​​​​更新start.sh脚本​​​​编写dockerfile​​​​准备资源配置清单​​​​DNS解析​​​​应用资源配置清单​​​​查看验证​​​​浏览器访问阿菠萝​​​​创建项目​​

下载安装包

下载官方release包:/opt/src]# mkdir -p /data/dockerfile/apollo-portal[root@k8s7-200.host.com /opt/src]# unzip -o apollo-portal-1.5.1-github.zip -d /data/dockerfile/apollo-portal/[root@k8s7-200.host.com /data/dockerfile/apollo-portal]# rm -rf apollo-portal-1.5.1-sources.jar apollo-portal.conf scripts/shutdown.sh2.下载sql文件 wget -O apolloportal.sql[root@k8s7-11.host.name ~]# mysql -uroot -p < apolloportal.sql MariaDB [(none)]> grant INSERT,DELETE,UPDATE,SELECT on ApolloPortalDB.* to "apolloportal"@"10.4.7.%" identified by "123456";3.修改部门信息MariaDB [ApolloPortalDB]> update ServerConfig set Value='[{"orgId":"scg01","orgName":"上海SCG部门"},{"orgId":"scg02","orgName":"北京SCG部门"},{"orgId":"scg03","orgName":"深圳SCG部门"}]' where Id=2;

更新start.sh脚本

[root@k8s7-200.host.com /data/dockerfile/apollo-portal/scripts]# cat startup.sh #!/bin/bashSERVICE_NAME=apollo-portal## Adjust log dir if necessaryLOG_DIR=/opt/logs/apollo-portal-server## Adjust server port if necessarySERVER_PORT=8080APOLLO_PORTAL_SERVICE_NAME=$(hostname -i)# SERVER_URL="Adjust memory settings if necessaryexport JAVA_OPTS="-Xms512m -Xmx512m -Xss256k -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=384m -XX:NewSize=256m -XX:MaxNewSize=256m -XX:SurvivorRatio=8"## Only uncomment the following when you are using server jvm#export JAVA_OPTS="$JAVA_OPTS -server -XX:-ReduceInitialCardMarks"########### The following is the same for configservice, adminservice, portal ###########export JAVA_OPTS="$JAVA_OPTSexport JAVA_OPTS="$JAVA_OPTS -Dserver.port=$SERVER_PORT -Dlogging.file=$LOG_DIR/$SERVICE_NAME.log -XX:HeapDumpPath=$LOG_DIR/HeapDumpOnOutOfMemoryError/"# Find Javaif [[ -n "$JAVA_HOME" ]] && [[ -x "$JAVA_HOME/bin/java" ]]; then javaexe="$JAVA_HOME/bin/java"elif type -p java > /dev/null 2>&1; then javaexe=$(type -p java)elif [[ -x "/usr/bin/java" ]]; then javaexe="/usr/bin/java"else echo "Unable to find Java" exit 1fiif [[ "$javaexe" ]]; then version=$("$javaexe" -version 2>&1 | awk -F '"' '/version/ {print $2}') version=$(echo "$version" | awk -F. '{printf("%03d%03d",$1,$2);}') # now version is of format 009003 (9.3.x) if [ $version -ge 011000 ]; then JAVA_OPTS="$JAVA_OPTS -Xlog:gc*:$LOG_DIR/gc.log:time,level,tags -Xlog:safepoint -Xlog:gc+heap=trace" elif [ $version -ge 010000 ]; then JAVA_OPTS="$JAVA_OPTS -Xlog:gc*:$LOG_DIR/gc.log:time,level,tags -Xlog:safepoint -Xlog:gc+heap=trace" elif [ $version -ge 009000 ]; then JAVA_OPTS="$JAVA_OPTS -Xlog:gc*:$LOG_DIR/gc.log:time,level,tags -Xlog:safepoint -Xlog:gc+heap=trace" else JAVA_OPTS="$JAVA_OPTS JAVA_OPTS="$JAVA_OPTS -Xloggc:$LOG_DIR/gc.log -XX:+PrintGCDetails" JAVA_OPTS="$JAVA_OPTS fifiprintf "$(date)cd `dirname $0`/..chmod 755 $SERVICE_NAME".jar"./$SERVICE_NAME".jar" startrc=$?;if [[ $rc != 0 ]];then echo "$(date) Failed to start $SERVICE_NAME.jar, return code: $rc" exit $rc;fitail

编写dockerfile

[root@k8s7-200.host.com /data/dockerfile/apollo-portal]# cat Dockerfile FROM harbor.od.com/base/jre8:8u112ENV VERSION 1.5.1RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime &&\ echo "Asia/Shanghai" > /etc/timezoneADD apollo-portal-${VERSION}.jar /apollo-portal/apollo-portal.jarADD config/ /apollo-portal/configADD scripts/ /apollo-portal/scriptsCMD ["/apollo-portal/scripts/startup.sh"]构建:[root@k8s7-200.host.com /data/dockerfile/apollo-portal]# docker build . -t harbor.od.com/infra/apollo-portal:v1.5.1[root@k8s7-200.host.com /data/dockerfile/apollo-portal]# docker push harbor.od.com/infra/apollo-portal:v1.5.1

准备资源配置清单

1.configmap.yaml[root@k8s7-200.host.com /data/k8s-yaml/apollo-portal]# cat configmap.yaml apiVersion: v1kind: ConfigMapmetadata: name: apollo-portal-cm namespace: infradata: application-github.properties: | # DataSource spring.datasource.url = jdbc:mysql://mysql.od.com:3306/ApolloPortalDB?characterEncoding=utf8 spring.datasource.username = apolloportal spring.datasource.password = 123456 app.properties: | appId=100003173 apollo-env.properties: | dev.meta=/data/k8s-yaml/apollo-portal]# cat deployment.yaml kind: DeploymentapiVersion: extensions/v1beta1metadata: name: apollo-portal namespace: infra labels: name: apollo-portalspec: replicas: 1 selector: matchLabels: name: apollo-portal template: metadata: labels: app: apollo-portal name: apollo-portal spec: volumes: - name: configmap-volume configMap: name: apollo-portal-cm containers: - name: apollo-portal image: harbor.od.com/infra/apollo-portal:v1.5.1 ports: - containerPort: 8080 protocol: TCP volumeMounts: - name: configmap-volume mountPath: /apollo-portal/config terminationMessagePath: /dev/termination-log terminationMessagePolicy: File imagePullPolicy: IfNotPresent imagePullSecrets: - name: harbor restartPolicy: Always terminationGracePeriodSeconds: 30 securityContext: runAsUser: 0 schedulerName: default-scheduler strategy: type: RollingUpdate rollingUpdate: maxUnavailable: 1 maxSurge: 1 revisionHistoryLimit: 7 progressDeadlineSeconds: 6003.service.yaml[root@k8s7-200.host.com /data/k8s-yaml/apollo-portal]# cat service.yaml kind: ServiceapiVersion: v1metadata: name: apollo-portal namespace: infraspec: ports: - protocol: TCP port: 8080 targetPort: 8080 selector: app: apollo-portal clusterIP: None type: ClusterIP sessionAffinity: None4.ingress.yaml[root@k8s7-200.host.com /data/k8s-yaml/apollo-portal]# cat ingress.yaml

DNS解析

/var/named/od.com.zoneportal A 10.4.7.10[root@k8s7-11.host.name ~]# dig -t A portal.od.com @10.4.7.11 +short

应用资源配置清单

[root@k8s7-22.host.com ~]# kubectl apply -f created[root@k8s7-22.host.com ~]# kubectl apply -f created[root@k8s7-22.host.com ~]# kubectl apply -f created[root@k8s7-22.host.com ~]# kubectl apply -f http://k8s-yaml.od.com/apollo-portal/ingress.yaml

查看验证

查看pod日志

浏览器访问阿菠萝

登进去首先修改默认密码

修改键值

创建项目

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:Kubernetes 健康检查之 livenessProbe/readinessProbe
下一篇:云游四方|历时13年打造,瑞士最大艺术博物馆今秋开放!
相关文章

 发表评论

暂时没有评论,来抢沙发吧~