k8s启动Envoy Deployment
k8s启动envoydeployment
·
1.创建envoy configmap,deploy,并启动&mount配置文件
创建envoy.yaml
admin:
address:
socket_address: { address: 127.0.0.1, port_value: 9901 }
static_resources:
listeners:
- name: listener_0
address:
socket_address: { address: 0.0.0.0, port_value: 10000 }
filter_chains:
- filters:
- name: envoy.filters.network.http_connection_manager
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
stat_prefix: ingress_http
codec_type: AUTO
route_config:
name: local_route
virtual_hosts:
- name: local_service
domains: ["*"]
routes:
- match: { prefix: "/" }
route: { cluster: some_service }
http_filters:
- name: envoy.filters.http.router
typed_config: ##新增
"@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router ##新增
clusters:
- name: some_service
connect_timeout: 0.25s
type: LOGICAL_DNS
lb_policy: ROUND_ROBIN
load_assignment:
cluster_name: some_service
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: nginx
port_value: 80
创建 ConfigMapkubectl create configmap envoy-config --from-file=envoy.yaml
创建envoy-deploy.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
run: envoy
name: envoy
spec:
replicas: 1
selector:
matchLabels:
run: envoy
template:
metadata:
labels:
run: envoy
spec:
containers:
- image: envoyproxy/envoy-dev
name: envoy
volumeMounts:
- name: envoy-config
mountPath: "/etc/envoy"
readOnly: true
volumes:
- name: envoy-config
configMap:
name: envoy-config
创建deploymentkubectl create -f envoy-deploy.yaml
暴露端口kubectl expose deploy envoy --selector run=envoy --port=10000 --type=NodePort
查看podkubectl get deploy,pod,svc -owide
请求端口:curl 10.101.234.29:10000
进入 Pod 查看 envoy 进程和配置
[root@k8s-master ~]# kubectl exec -it envoy-fb5d77cc9-gq9fb /bin/bash
kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead.
root@envoy-fb5d77cc9-gq9fb:/#
在pod里面执行ps -ef
以及cat /etc/envoy/envoy.yaml
更改配置的监听端口并测试访问入口的变化
编辑configmap修改监听端口10000为18888
kubectl edit configmap envoy-config
删除旧的podkubectl delete pod envoy-fb5d77cc9-gq9fb
修改svc配置 kubectl edit svc envoy
,将端口改为18888
通过非级联删除的方法逐个删除对象
1.删除deploymentkubectl delete deploy envoy --cascade=orphan
2.删除 replicationsetkubectl delete rs envoy-fb5d77cc9 --cascade=orphan
3.删除podkubectl delete pod envoy-fb5d77cc9-gq9fb
更多推荐
已为社区贡献2条内容
所有评论(0)