Skip to content

Commit

Permalink
feat: Add the merge switch of gportal and api-plane components (#59)
Browse files Browse the repository at this point in the history
Signed-off-by: xianyanglin <[email protected]>
  • Loading branch information
xianyanglin committed Jun 6, 2023
1 parent 54a472f commit a35e417
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 79 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,45 @@ apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: hango-api-plane
name: hango-api-plane
portal-container: hango-portal
api-plane-container: hango-api-plane
name: hango-portal
namespace: {{ .Values.namespace }}
spec:
replicas: {{ .Values.replicas }}
strategy:
rollingUpdate:
maxSurge: 1
maxUnavailable: 1
selector:
matchLabels:
app: hango-api-plane
portal-container: hango-portal
api-plane-container: hango-api-plane
template:
metadata:
labels:
app: hango-api-plane
portal-container: hango-portal
api-plane-container: hango-api-plane
spec:
serviceAccount: hango-apiplane
containers:
- env:
- name: hango-portal
env:
- name: NCE_PORT
value: "11113"
image: "{{ .Values.images.hango_portal_image }}"
resources:
requests:
memory: 800Mi
limits:
memory: 1024Mi
imagePullPolicy: IfNotPresent
volumeMounts:
- mountPath: /usr/local/tomcat/logs
name: portal-log
- mountPath: /usr/local/tomcat/webapps/ROOT/WEB-INF/classes/gdashboard-jdbc.properties
subPath: gdashboard-jdbc.properties
name: hango-portal-config
- mountPath: /usr/local/tomcat/webapps/ROOT/WEB-INF/classes/data.sql
subPath: data.sql
name: hango-portal-config
- name: api-plane
env:
- name: NCE_PORT
value: "10880"
- name: NCE_JAVA_OPTS
Expand All @@ -33,11 +52,10 @@ spec:
memory: 800Mi
limits:
memory: 1024Mi
name: tomcat
imagePullPolicy: IfNotPresent
volumeMounts:
- mountPath: /usr/local/tomcat/logs
name: log
name: plane-log
- mountPath: /usr/local/tomcat/webapps/ROOT/WEB-INF/classes/k8s.yaml
name: k8s-conf
subPath: k8s.yaml
Expand All @@ -50,9 +68,20 @@ spec:
- mountPath: /usr/local/tomcat/webapps/ROOT/WEB-INF/classes/template/plugin/route
name: hango-plugin
volumes:
- hostPath:
path: {{ .Values.data_dir }}/log/hango-portal
name: portal-log
- configMap:
name: hango-portal-config
items:
- key: gdashboard-jdbc.properties
path: gdashboard-jdbc.properties
- key: data.sql
path: data.sql
name: hango-portal-config
- hostPath:
path: {{ .Values.data_dir }}/log/hango-api-plane
name: log
name: plane-log
- configMap:
defaultMode: 420
items:
Expand Down Expand Up @@ -80,60 +109,7 @@ spec:
name: hango-plugin
restartPolicy: Always
dnsPolicy: ClusterFirstWithHostNet
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
nce-app: hango-portal
name: hango-portal
namespace: {{ .Values.namespace }}
spec:
replicas: {{ .Values.replicas }}
selector:
matchLabels:
app: hango-portal
template:
metadata:
labels:
app: hango-portal
spec:
containers:
- name: tomcat
env:
- name: NCE_PORT
value: "11113"
image: "{{ .Values.images.hango_portal_image }}"
resources:
requests:
memory: 800Mi
limits:
memory: 1024Mi
imagePullPolicy: IfNotPresent
volumeMounts:
- mountPath: /usr/local/tomcat/logs
name: log
- mountPath: /usr/local/tomcat/webapps/ROOT/WEB-INF/classes/gdashboard-jdbc.properties
subPath: gdashboard-jdbc.properties
name: hango-portal-config
- mountPath: /usr/local/tomcat/webapps/ROOT/WEB-INF/classes/data.sql
subPath: data.sql
name: hango-portal-config
volumes:
- hostPath:
path: {{ .Values.data_dir }}/log/hango-portal
name: log
- configMap:
name: hango-portal-config
items:
- key: gdashboard-jdbc.properties
path: gdashboard-jdbc.properties
- key: data.sql
path: data.sql
name: hango-portal-config
restartPolicy: Always
dnsPolicy: ClusterFirstWithHostNet

serviceAccount: hango-apiplane
---
apiVersion: apps/v1
kind: Deployment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ spec:
targetPort: 10880
name: http
selector:
app: hango-api-plane
api-plane-container: hango-api-plane

---
apiVersion: v1
Expand All @@ -29,7 +29,7 @@ spec:
- port: 80
targetPort: 11113
selector:
app: hango-portal
portal-container: hango-portal

---
apiVersion: v1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ registry:
## 刷新zookeeper服务缓存的时间周期,默认15s,格式为: [正整数]s
refresh_period: 15s
## 注册中心实例地址;格式:整体以英文单引号包裹,单个地址以英文双引号包裹,多个地址用英文逗号分隔
address: '"zookeeper.apigw-demo.svc.cluster.local:2181"'
address: '"zookeeper.apigw-demo.svc.cluster.local:2181"'
39 changes: 30 additions & 9 deletions install/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,36 @@ function helm_install_for_hango_component() {
}

function verify_hango_install() {
while true
do
sleep 10s
pod_number=`kubectl -n $HANGO_NAMESPACE get pods | grep Running | wc -l`
if [[ $pod_number -ge 7 ]]; then
echo "hango pod running"
break
fi
done
sleep 10
while true; do
# 获取命名空间中所有的 Deployment 名称
DEPLOYMENTS="$(kubectl get deploy -n ${HANGO_NAMESPACE} -o jsonpath='{.items[*].metadata.name}')"

# 遍历所有的 Deployment
for DEPLOYMENT_NAME in ${DEPLOYMENTS}; do
# 获取 Deployment 的当前状态
DEPLOYMENT_STATUS="$(kubectl get deployment ${DEPLOYMENT_NAME} -n ${HANGO_NAMESPACE} -o jsonpath='{.status}')"

# 解析 Deployment 可用 Pod 的数量和总数
AVAILABLE="$(echo ${DEPLOYMENT_STATUS} | jq -r '.availableReplicas')"
DESIRED="$(echo ${DEPLOYMENT_STATUS} | jq -r '.replicas')"

# 判断 Deployment 是否就绪
if [[ ${AVAILABLE} -eq ${DESIRED} ]]; then
echo "Deployment ${DEPLOYMENT_NAME} is ready."
else
echo "Deployment ${DEPLOYMENT_NAME} is not ready yet. Waiting..."
# 如果有任何一个 Deployment 不就绪,则退出循环
continue 2
fi
done

# 所有的 Deployment 都就绪,退出循环
echo "All deployments are ready."
break

sleep 5
done
}

function init_for_namespaces() {
Expand Down

0 comments on commit a35e417

Please sign in to comment.