创建K8s命名空间
namespace.yaml
apiVersion: v1
kind: Namespace
metadata:
name: apollo
apollo-portal的web界面管理端
portal-configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: apollo-portal
namespace: apollo
data:
application-github.properties: |
spring.datasource.url = jdbc:mysql://172.30.20.31:3306/apolloportaldb?characterEncoding=utf8
spring.datasource.username = root
spring.datasource.password = 123123
apollo-env.properties: |
local.meta=http://apollo-portal:8080
dev.meta = http://apollo-dev-configservice:8080 #环境的端口,如果下面的fat,pro环境
eureka.service.url = http://apollo-dev-configservice:8080
#fat.meta=http://apollo-fat-configservice:8080
#pro.meta=http://apollo-pro-configservice:8080
#eureka.service.url = http://apollo-dev-configservice:8080,http://apollo-pro-configservice:8080,http://apollo-fat-configservice:8080
portal-deploy.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: apollo-portal
namespace: apollo
labels:
app: apollo-portal
spec:
replicas: 1
selector:
matchLabels:
app: apollo-portal
template:
metadata:
labels:
app: apollo-portal
spec:
containers:
- name: apollo-portal
image: apolloconfig/apollo-portal:latest
imagePullPolicy: IfNotPresent
ports:
- name: http
containerPort: 8070
protocol: TCP
env:
- name: SPRING_PROFILES_ACTIVE
value: "github,auth"
resources:
limits:
cpu: "1000m"
memory: "1024Mi"
requests:
cpu: "1000m"
memory: "1024Mi"
volumeMounts:
- name: apollo-portal-config
mountPath: /apollo-portal/config/application-github.properties
subPath: application-github.properties
- name: apollo-portal-config
mountPath: /apollo-portal/config/apollo-env.properties
subPath: apollo-env.properties
volumes:
- name: apollo-portal-config
configMap:
name: apollo-portal
items:
- key: application-github.properties
path: application-github.properties
- key: apollo-env.properties
path: apollo-env.properties
defaultMode: 420
portal-svc.yaml
apiVersion: v1
kind: Service
metadata:
name: apollo-portal
namespace: apollo
labels:
app: apollo-portal
spec:
selector:
app: apollo-portal
ports:
- name: http
protocol: TCP
port: 8070
targetPort: 8070
DEV环境的admin和config
adminservice-configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: apollo-dev-adminservice
namespace: apollo
data:
application-github.properties: |
spring.datasource.url = jdbc:mysql://172.30.20.31:3306/apolloconfigdb_dev?characterEncoding=utf8
spring.datasource.username = root
spring.datasource.password = 123123
eureka.service.url = http://apollo-dev-configservice:8080/eureka/
configservice-configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: apollo-dev-configservice
namespace: apollo
data:
application-github.properties: |
spring.datasource.url = jdbc:mysql://172.30.20.31:3306/apolloconfigdb_dev?characterEncoding=utf8
spring.datasource.username = root
spring.datasource.password = 123123
apollo.config-service.url = http://apollo-dev-configservice:8080
apollo.admin-service.url = http://apollo-dev-adminservice:8090
eureka.service.url = http://apollo-dev-configservice:8080/eureka/
adminservice-deploy.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: apollo-dev-adminservice
namespace: apollo
labels:
app: apollo-dev-adminservice
spec:
replicas: 1
selector:
matchLabels:
app: apollo-dev-adminservice
template:
metadata:
labels:
app: apollo-dev-adminservice
spec:
containers:
- name: apollo-dev-adminservice
image: apolloconfig/apollo-adminservice:latest
imagePullPolicy: IfNotPresent
ports:
- name: http
containerPort: 8090
protocol: TCP
env:
- name: SPRING_PROFILES_ACTIVE
value: "github,kubernetes"
resources:
limits:
cpu: "1000m"
memory: "1024Mi"
requests:
cpu: "1000m"
memory: "1024Mi"
volumeMounts:
- name: apollo-adminservice-config
mountPath: /apollo-adminservice/config/application-github.properties
subPath: application-github.properties
volumes:
- name: apollo-adminservice-config
configMap:
name: apollo-dev-adminservice
items:
- key: application-github.properties
path: application-github.properties
defaultMode: 420
configserivce-deploy.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: apollo-dev-configservice
namespace: apollo
labels:
app: apollo-dev-configservice
spec:
replicas: 1
selector:
matchLabels:
app: apollo-dev-configservice
template:
metadata:
labels:
app: apollo-dev-configservice
spec:
containers:
- name: apollo-dev-configservice
image: apolloconfig/apollo-configservice:latest
imagePullPolicy: IfNotPresent
ports:
- name: http
containerPort: 8080
protocol: TCP
env:
- name: SPRING_PROFILES_ACTIVE
value: "github,kubernetes"
resources:
limits:
cpu: "1000m"
memory: "1024Mi"
requests:
cpu: "1000m"
memory: "1024Mi"
volumeMounts:
- name: apollo-configservice-config
mountPath: /apollo-configservice/config/application-github.properties
subPath: application-github.properties
volumes:
- name: apollo-configservice-config
configMap:
name: apollo-dev-configservice
items:
- key: application-github.properties
path: application-github.properties
defaultMode: 420
adminservice-svc.yaml
apiVersion: v1
kind: Service
metadata:
name: apollo-dev-adminservice
namespace: apollo
labels:
app: apollo-dev-adminservice
spec:
selector:
app: apollo-dev-adminservice
ports:
- name: http
protocol: TCP
port: 8090
targetPort: 8090
configservice-svc.yaml
apiVersion: v1
kind: Service
metadata:
name: apollo-dev-configservice
namespace: apollo
labels:
app: apollo-dev-configservice
spec:
selector:
app: apollo-dev-configservice
ports:
- name: http
protocol: TCP
port: 8080
targetPort: 8080
注:如果有其他环境配置需要对照dev环境的配置修改一下数据库连接地址,再配置一下portal,即可