k8s部署apollo
k8s以Deployment方式部署apollo。最新版本:1.7.1public-service-ns.yamlapiVersion: v1kind: Namespacemetadata:name: public-serviceapollo.yamlapiVersion: v1kind: ConfigMapmetadata:name: apollo-configservicenamespace:
·
k8s以Deployment方式部署apollo。最新版本:1.7.1
public-service-ns.yaml
apiVersion: v1
kind: Namespace
metadata:
name: public-service
apollo.yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: apollo-configservice
namespace: public-service
data:
application-github.properties: |
spring.datasource.url = jdbc:mysql://192.168.30.131:3306/ApolloConfigDB?characterEncoding=utf8
spring.datasource.username = root
spring.datasource.password = 123456789
apollo.config-service.url = http://apollo-configservice.public-service:8080
apollo.admin-service.url = http://apollo-adminservice.public-service:8090
---
apiVersion: v1
kind: ConfigMap
metadata:
name: apollo-adminservice
namespace: public-service
data:
application-github.properties: |
spring.datasource.url = jdbc:mysql://192.168.30.131:3306/ApolloConfigDB?characterEncoding=utf8
spring.datasource.username = root
spring.datasource.password = 123456789
---
apiVersion: v1
kind: ConfigMap
metadata:
name: apollo-portal
namespace: public-service
data:
application-github.properties: |
spring.datasource.url = jdbc:mysql://192.168.30.131:3306/ApolloPortalDB?characterEncoding=utf8
spring.datasource.username = root
spring.datasource.password = 123456789
apollo.portal.envs = dev
apollo-env.properties: |
dev.meta = http://apollo-configservice:8080
---
apiVersion: v1
kind: Service
metadata:
name: apollo-configservice
namespace: public-service
labels:
app: apollo-configservice
spec:
selector:
app: apollo-configservice
ports:
- name: http
protocol: TCP
port: 8080
targetPort: 8080
---
apiVersion: v1
kind: Service
metadata:
name: apollo-adminservice
namespace: public-service
labels:
app: apollo-adminservice
spec:
selector:
app: apollo-adminservice
ports:
- name: http
protocol: TCP
port: 8090
targetPort: 8090
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: apollo-portal
namespace: public-service
labels:
app: apollo-portal
spec:
rules:
- host: apollo.lzxlinux.com
http:
paths:
- path: /
backend:
serviceName: apollo-portal
servicePort: 8070
---
apiVersion: v1
kind: Service
metadata:
name: apollo-portal
namespace: public-service
labels:
app: apollo-portal
spec:
selector:
app: apollo-portal
sessionAffinity: ClientIP
ports:
- name: http
protocol: TCP
port: 8070
targetPort: 8070
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: apollo-configservice
namespace: public-service
labels:
app: apollo-configservice
spec:
replicas: 1
selector:
matchLabels:
app: apollo-configservice
template:
metadata:
labels:
app: apollo-configservice
spec:
containers:
- name: apollo-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-configservice
items:
- key: application-github.properties
path: application-github.properties
defaultMode: 420
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: apollo-adminservice
namespace: public-service
labels:
app: apollo-adminservice
spec:
replicas: 1
selector:
matchLabels:
app: apollo-adminservice
template:
metadata:
labels:
app: apollo-adminservice
spec:
containers:
- name: apollo-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-adminservice
items:
- key: application-github.properties
path: application-github.properties
defaultMode: 420
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: apollo-portal
namespace: public-service
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
git clone https://github.com/ctripcorp/apollo.git
mysql -uroot -p123456789 < apollo/scripts/sql/apolloportaldb.sql
mysql -uroot -p123456789 < apollo/scripts/sql/apolloconfigdb.sql
kubectl apply -f public-service-ns.yaml
kubectl apply -f apollo.yaml
kubectl get svc -n public-service
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
apollo-adminservice ClusterIP 10.110.239.51 <none> 8090/TCP 14s
apollo-configservice ClusterIP 10.103.129.253 <none> 8080/TCP 14s
apollo-portal ClusterIP 10.105.237.238 <none> 8070/TCP 13s
kubectl get pod -n public-service
NAME READY STATUS RESTARTS AGE
apollo-adminservice-765497fbbc-htskm 1/1 Running 0 35s
apollo-configservice-64b4d77457-8w59g 1/1 Running 0 35s
apollo-portal-5f585dc954-th96h 1/1 Running 0 34s
添加hosts:apollo.lzxlinux.com
,账号/密码:apollo
/admin
。
k8s部署apollo完成。已存放至个人github:kubernetes
更多推荐
已为社区贡献29条内容
所有评论(0)