我有一个在公司代理后面运行的 Kubernetes 集群。我没有使用 Minikube。我有http_proxy
,https_proxy
并no_proxy
设置在 //etc/environment. no_proxy 有 127.0.0.0 和每个 node-ip 定义。
如果我尝试从我的主节点使用 ClusterIP 卷曲服务,我会陷入公司代理。我需要做什么才能访问该服务?将服务更改为 NodePort 并从集群外部访问它是可行的。
我希望有人可以向我解释我所缺少的。提前致谢。
部署和服务的 Yaml 文件
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
run: app
name: app-blue
spec:
replicas: 1
selector:
matchLabels:
run: app
version: 0.0.1
template:
metadata:
labels:
run: app
version: 0.0.1
spec:
containers:
- name: app
image: errm/versions:0.0.1
ports:
- containerPort: 3000
----
apiVersion: v1
kind: Service
metadata:
name: app-service
spec:
selector:
run: app
version: 0.0.1
ports:
- name: http
port: 80
protocol: TCP
targetPort: 3000
Kubectl 描述服务
Name: app-service
Namespace: default
Labels: <none>
Annotations: <none>
Selector: run=app,version=0.0.1
Type: ClusterIP
IP Families: <none>
IP: 10.107.64.107
IPs: 10.107.64.107
Port: http 80/TCP
TargetPort: 3000/TCP
Endpoints: 10.244.2.4:3000
Session Affinity: None
Events: <none>
从主节点卷曲
curl 10.107.64.107:80
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="de" lang="de" xml:lang="de" xmlns="http://www.w3.org/1999/xhtml">
<!--Head-->
<head>
<meta content="IE=11.0000" http-equiv="X-UA-Compatible">
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>McAfee Web Gateway - Notification</title>
<script src="/mwg-internal/de5fs23hu73ds/files/javascript/sw.js" type="text/javascript" ></script>
<link rel="stylesheet" href="/mwg-internal/de5fs23hu73ds/files/default/web.css" />
</head>
<!--/Head-->
<!--Body-->
<body onload="swOnLoad();" class="background">
<div class="inner_frame">
<div class="head_right_text">
<img alt="Logo" class="emblem" src='/mwg-internal/de5fs23hu73ds/files/default/img/wappen.png'>
</div>
<img alt="Logo" class="lion_left" src='/mwg-internal/de5fs23hu73ds/files/default/img/bg_loewe_links.png'>
<img alt="Logo" class="lion_right" src='/mwg-internal/de5fs23hu73ds/files/default/img/bg_loewe_rechts.png'>
<!--Contents-->
<div class="msg_border">
<div class="msg_head">
Keine Verbindung möglich.
</div>
<div class="msg_text">
<p>
Der Proxy hat eine ungültige Antwort erhalten.
</p>
</div>
</div>
<!--/Contents-->
</div>
</body>
<!--/Body-->
</html>