标签:check spro none temp start ali png str seconds
目前官方稳文档没有写,但是demo 里面有,所以就整理出来,其实目前demo里面的
多实例部署用了多个服务的service(使用nodeport 暴露地址,具体使用就是制定ambassador
实例的id 部署的时候使用环境变量,service mapping 的时候指定id (可以指定多个)
两个ambassador实例部署在default以及test命名空间
ambassador-no-rbac.yaml
---
apiVersion: v1
kind: Service
metadata:
labels:
service: ambassador-admin
name: ambassador-admin
spec:
type: NodePort
ports:
- name: ambassador-admin
port: 8877
targetPort: 8877
selector:
service: ambassador
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: ambassador
spec:
replicas: 3
template:
metadata:
annotations:
sidecar.istio.io/inject: "false"
labels:
service: ambassador
spec:
containers:
- name: ambassador
image: quay.io/datawire/ambassador:0.35.1
resources:
limits:
cpu: 1
memory: 400Mi
requests:
cpu: 200m
memory: 100Mi
env:
- name: AMBASSADOR_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: AMBASSADOR_ID
value: ambassador-1
livenessProbe:
httpGet:
path: /ambassador/v0/check_alive
port: 8877
initialDelaySeconds: 30
periodSeconds: 3
readinessProbe:
httpGet:
path: /ambassador/v0/check_ready
port: 8877
initialDelaySeconds: 30
periodSeconds: 3
- name: statsd
image: quay.io/datawire/statsd:0.35.1
restartPolicy: Always
ambassador-no-rbac-test.yaml
---
apiVersion: v1
kind: Service
metadata:
labels:
service: ambassador-admin
name: ambassador-admin
namespace: test
spec:
type: NodePort
ports:
- name: ambassador-admin
port: 8877
targetPort: 8877
selector:
service: ambassador
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: ambassador
namespace: test
spec:
replicas: 3
template:
metadata:
annotations:
sidecar.istio.io/inject: "false"
labels:
service: ambassador
spec:
containers:
- name: ambassador
image: quay.io/datawire/ambassador:0.35.1
resources:
limits:
cpu: 1
memory: 400Mi
requests:
cpu: 200m
memory: 100Mi
env:
- name: AMBASSADOR_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: AMBASSADOR_ID
value: ambassador-2
livenessProbe:
httpGet:
path: /ambassador/v0/check_alive
port: 8877
initialDelaySeconds: 30
periodSeconds: 3
readinessProbe:
httpGet:
path: /ambassador/v0/check_ready
port: 8877
initialDelaySeconds: 30
periodSeconds: 3
- name: statsd
image: quay.io/datawire/statsd:0.35.1
restartPolicy: Always
ambassador-service.yaml
---
apiVersion: v1
kind: Service
metadata:
name: ambassador
spec:
type: NodePort
ports:
- port: 80
selector:
service: ambassador
ambassador-service-test.yaml
---
apiVersion: v1
kind: Service
metadata:
name: ambassador
namespace: test
spec:
type: NodePort
ports:
- port: 80
selector:
service: ambassador
deploy
kubectl apply -f ambassador-no-rbac.yaml -f ambassador-no-rbac-test.yaml
service
kubectl apply -f ambassador-service.yaml -f ambassador-service-test.yaml
创建多个service
- demo-1 && demo-2
demo-1.yaml
---
apiVersion: v1
kind: Service
metadata:
name: demo1
namespace: test-svc
annotations:
getambassador.io/config: |
---
apiVersion: ambassador/v0
kind: Mapping
name: demo_mapping
ambassador_id: ambassador-1
prefix: /demo/
service: demo1
---
apiVersion: ambassador/v0
kind: Mapping
name: joint_1_mapping
ambassador_id:
- ambassador-1
- ambassador-2
prefix: /demo/
headers:
x-demo-mode: joint
service: demo1
---
apiVersion: ambassador/v0
kind: Mapping
name: should_not_appear_1
prefix: /joint/
service: demo1
spec:
selector:
app: demo1
ports:
- port: 80
targetPort: http-api
type: ClusterIP
---
apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: demo1
namespace: test-svc
spec:
replicas: 1
strategy:
type: RollingUpdate
template:
metadata:
labels:
app: demo1
spec:
containers:
- name: demo1
image: dwflynn/demo:1.0.0
imagePullPolicy: Always
ports:
- name: http-api
containerPort: 3000
demo-2.yaml
---
apiVersion: v1
kind: Service
metadata:
name: demo2
namespace: test-svc
annotations:
getambassador.io/config: |
---
apiVersion: ambassador/v0
kind: Mapping
name: demo_mapping
ambassador_id: ambassador-2
prefix: /demo/
service: demo2.test-svc
---
apiVersion: ambassador/v0
kind: Mapping
name: joint_2_mapping
ambassador_id: [ "ambassador-1", "ambassador-2" ]
prefix: /demo/
headers:
x-demo-mode: joint
weight: 25
service: demo2.test-svc
---
apiVersion: ambassador/v0
kind: Mapping
name: should_not_appear_2
prefix: /joint/
service: demo2.test-svc
spec:
selector:
app: demo2
ports:
- port: 80
targetPort: http-api
type: ClusterIP
---
apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: demo2
namespace: test-svc
spec:
replicas: 1
strategy:
type: RollingUpdate
template:
metadata:
labels:
app: demo2
spec:
containers:
- name: demo2
image: dwflynn/demo:2.0.0
imagePullPolicy: Always
ports:
- name: http-api
containerPort: 3000
kubectl apply -f demo-1.yaml -f demo-2.yaml
admin 地址 http://hostip:nodeport/ambassador/v0/diag
ambassador-1(default 命名空间 nodeport 30168)
ambassador-2(test命名空间 nodeport 30786)
说明
从服务mapping 以及监控界面看到的和服务注册的是一致的
https://github.com/datawire/ambassador/tree/v0.32.1/end-to-end/010-multiple-ambassadors
https://github.com/rongfengliang/ambassador-learning
ambassador 学习九 多ambassador部署说明
标签:check spro none temp start ali png str seconds
原文地址:https://www.cnblogs.com/rongfengliang/p/9275700.html