- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想要达到的目标:阻止所有流向服务的流量,包含在与服务相同的命名空间内处理此流量的代码。
为什么:这是将特定服务“锁定”到特定 IP/CIDR 的第一步
我有一个名为 istio-ingressgateway
的主要入口 GW这适用于服务。
$ kubectl describe gw istio-ingressgateway -n istio-system
Name: istio-ingressgateway
Namespace: istio-system
Labels: operator.istio.io/component=IngressGateways
operator.istio.io/managed=Reconcile
operator.istio.io/version=1.5.5
release=istio
Annotations: API Version: networking.istio.io/v1beta1
Kind: Gateway
Metadata:
Creation Timestamp: 2020-08-28T15:45:10Z
Generation: 1
Resource Version: 95438963
Self Link: /apis/networking.istio.io/v1beta1/namespaces/istio-system/gateways/istio-ingressgateway
UID: ae5dd2d0-44a3-4c2b-a7ba-4b29c26fa0b9
Spec:
Selector:
App: istio-ingressgateway
Istio: ingressgateway
Servers:
Hosts:
*
Port:
Name: http
Number: 80
Protocol: HTTP
Events: <none>
我还有另一个“主要”GW,即 K8s 入口 GW 来支持 TLS(我想我会包括这个,尽可能明确)
k describe gw istio-autogenerated-k8s-ingress -n istio-system
Name: istio-autogenerated-k8s-ingress
Namespace: istio-system
Labels: app=istio-ingressgateway
istio=ingressgateway
operator.istio.io/component=IngressGateways
operator.istio.io/managed=Reconcile
operator.istio.io/version=1.5.5
release=istio
Annotations: API Version: networking.istio.io/v1beta1
Kind: Gateway
Metadata:
Creation Timestamp: 2020-08-28T15:45:56Z
Generation: 2
Resource Version: 95439499
Self Link: /apis/networking.istio.io/v1beta1/namespaces/istio-system/gateways/istio-autogenerated-k8s-ingress
UID: edd46c17-9975-4089-95ff-a2414d40954a
Spec:
Selector:
Istio: ingressgateway
Servers:
Hosts:
*
Port:
Name: http
Number: 80
Protocol: HTTP
Hosts:
*
Port:
Name: https-default
Number: 443
Protocol: HTTPS
Tls:
Credential Name: ingress-cert
Mode: SIMPLE
Private Key: sds
Server Certificate: sds
Events: <none>
我希望能够在命名空间
x
中创建另一个 GW并具有附加到该 GW 的授权策略。
istio-system
中创建授权策略命名空间,然后返回
RBAC: access denied
这很棒 - 但这适用于使用主 GW 的所有服务。
apiVersion: security.istio.io/v1beta1
kind: AuthorizationPolicy
metadata:
name: block-all
namespace: istio-system
spec:
selector:
matchLabels:
app: istio-ingressgateway
action: DENY
rules:
- from:
- source:
ipBlocks: ["0.0.0.0/0"]
我目前拥有的不起作用。任何指针将不胜感激。以下都是在
x
下创建的应用
kubectl apply -f files.yaml -n x
时的命名空间
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
annotations:
app: x-ingress
name: x-gw
labels:
app: x-ingress
spec:
selector:
istio: ingressgateway
servers:
- hosts:
- x.y.com
port:
name: http
number: 80
protocol: HTTP
tls:
httpsRedirect: true
- hosts:
- x.y.com
port:
name: https
number: 443
protocol: HTTPS
tls:
mode: SIMPLE
privateKey: sds
serverCertificate: sds
credentialName: ingress-cert
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: x
labels:
app: x
spec:
hosts:
- x.y.com
gateways:
- x-gw
http:
- route:
- destination:
host: x
---
apiVersion: security.istio.io/v1beta1
kind: AuthorizationPolicy
metadata:
name: x-ingress-policy
spec:
selector:
matchLabels:
app: x-ingress
action: DENY
rules:
- from:
- source:
ipBlocks: ["0.0.0.0/0"]
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: x
labels:
app: x
spec:
hosts:
- x.y.com
gateways:
- x-gw
http:
- route:
- destination:
host: x
以上应该阻止所有到 GW 的流量,因为它匹配
0.0.0.0/0
的 CIDR 范围。
apiVersion: install.istio.io/v1alpha1
kind: IstioOperator
metadata:
namespace: istio-system
name: istiocontrolplane
spec:
profile: demo
components:
ingressGateways:
- name: istio-ingressgateway
enabled: true
- name: admin-ingressgateway
enabled: true
label:
istio: admin-ingressgateway
k8s:
serviceAnnotations:
service.beta.kubernetes.io/aws-load-balancer-type: "nlb"
---
apiVersion: security.istio.io/v1beta1
kind: AuthorizationPolicy
metadata:
name: deny-all-admin
namespace: istio-system
spec:
selector:
matchLabels:
istio: admin-ingressgateway
action: ALLOW
rules:
- from:
- source:
ipBlocks: ["176.252.114.59/32"]
kubectl patch svc istio-ingressgateway -n istio-system -p '{"spec":{"externalTrafficPolicy":"Local"}}'
然后,我在我想要锁定的工作负载中使用了该网关。
最佳答案
据我所知你应该使用 AuthorizationPolicy 3种方式
apiVersion: security.istio.io/v1beta1
kind: AuthorizationPolicy
metadata:
name: deny-all
namespace: x
spec:
{}
以下授权策略拒绝入口网关上的所有请求。
apiVersion: security.istio.io/v1beta1
kind: AuthorizationPolicy
metadata:
name: deny-all
namespace: istio-system
spec:
selector:
matchLabels:
app: istio-ingressgateway
以下授权策略拒绝对
httpbin 的所有请求在 x 命名空间中。
apiVersion: security.istio.io/v1beta1
kind: AuthorizationPolicy
metadata:
name: deny-service-x
namespace: x
spec:
selector:
matchLabels:
app: httpbin
apiVersion: security.istio.io/v1beta1
kind: AuthorizationPolicy
metadata:
name: deny-all
namespace: x
spec:
{}
而这个 AuthorizationPolicy 只允许获取请求。
apiVersion: "security.istio.io/v1beta1"
kind: "AuthorizationPolicy"
metadata:
name: "x-viewer"
namespace: x
spec:
selector:
matchLabels:
app: httpbin
rules:
- to:
- operation:
methods: ["GET"]
I guess the reason why it’s stop working when in non ingress pod is because the sourceIP attribute will not be the real client IP then.
According to https://github.com/istio/istio/issues/22341 7, (not done yet) this aims at providing better support without setting k8s externalTrafficPolicy to local, and supports CIDR range as well.
externalTrafficPolicy
.然后是
envoyfilter 的解决方法来自上面的 istio 讨论线程。
Got and example working successfully using EnvoyFilters, specifically with remote_ip condition applied on httbin.
Sharing the manifest for reference.
apiVersion: networking.istio.io/v1alpha3
kind: EnvoyFilter
metadata:
name: httpbin
namespace: foo
spec:
workloadSelector:
labels:
app: httpbin
configPatches:
- applyTo: HTTP_FILTER
match:
context: SIDECAR_INBOUND
listener:
filterChain:
filter:
name: "envoy.http_connection_manager"
subFilter:
name: "envoy.router"
patch:
operation: INSERT_BEFORE
value:
name: envoy.filters.http.rbac
config:
rules:
action: ALLOW
policies:
"ip-premissions":
permissions:
- any: true
principals:
- remote_ip:
address_prefix: xxx.xxx.xx.xx
prefix_len: 32
kubectl patch svc istio-ingressgateway -n istio-system -p '{"spec":{"externalTrafficPolicy":"Local"}}'
2.我已经创建了命名空间 x 并启用了 istio-injection 并在此处部署了 httpbin。
kubectl create namespace x
kubectl label namespace x istio-injection=enabled
kubectl apply -f https://raw.githubusercontent.com/istio/istio/release-1.7/samples/httpbin/httpbin.yaml -n x
kubectl apply -f https://github.com/istio/istio/blob/master/samples/httpbin/httpbin-gateway.yaml -n x
3.我已经创建了envoyfilter
apiVersion: networking.istio.io/v1alpha3
kind: EnvoyFilter
metadata:
name: httpbin
namespace: x
spec:
workloadSelector:
labels:
app: httpbin
configPatches:
- applyTo: HTTP_FILTER
match:
context: SIDECAR_INBOUND
listener:
filterChain:
filter:
name: "envoy.http_connection_manager"
subFilter:
name: "envoy.router"
patch:
operation: INSERT_BEFORE
value:
name: envoy.filters.http.rbac
config:
rules:
action: ALLOW
policies:
"ip-premissions":
permissions:
- any: true
principals:
- remote_ip:
address_prefix: xx.xx.xx.xx
prefix_len: 32
address_prefix 是
CLIENT_IP ,有我用过的命令来获取它。
export INGRESS_HOST=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
export INGRESS_PORT=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.spec.ports[?(@.name=="http2")].port}')
curl "$INGRESS_HOST":"$INGRESS_PORT"/headers -s -o /dev/null -w "%{http_code}\n"
CLIENT_IP=$(curl "$INGRESS_HOST":"$INGRESS_PORT"/ip -s | grep "origin" | cut -d'"' -f 4) && echo "$CLIENT_IP"
4.我用curl和我的浏览器测试过。
curl "$INGRESS_HOST":"$INGRESS_PORT"/headers -s -o /dev/null -w "%{http_code}\n"
200
关于kubernetes - Istio 授权策略不适用于子网关,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63647973/
据我所知,标准 jQuery“切换”功能在 jQuery mobile 中不起作用 - 这是正确的吗?如果是这样,还有其他有效的方法吗?我想做的就是打开和关闭“播放”按钮。所以按钮 ID 是“play
他们要求我提供一个“切换按钮”来打开和关闭集群有人可以帮助我实现集群的打开/关闭吗? 注意:加载超过30,000点 最佳答案 创建两层,一层有标记聚类,一层没有标记聚类,并将它们添加到传单控件中。例如
所以我想让我的 Python Gtk 小窗口有 2 个开关。当一个开关打开时,另一个开关关闭,反之亦然。我不太清楚如何控制这两个开关。如果有人能引导我走向正确的方向,我将不胜感激。 #!/usr/bi
按照目前的情况,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the
我为我的 android 应用程序集成了推送通知,我想为任何 android 手机/标签打开/关闭推送通知,任何人都可以帮助我... protected void onPostExecute(Blog
我遇到无法更改的问题 Switch运行时的 textOn/textOff 内容。这意味着,绑定(bind)到简单按钮(用于测试目的)的以下代码不起作用: private int _counter =
我正在开发一个应用程序来测试 iPhone 屏幕是关闭还是打开,我尝试了堆栈溢出中指定的加速度计代码,它在屏幕开启状态下运行良好,但是当我关闭屏幕时,加速度计没有停用。 所以我开始怀疑当屏幕关闭时加速
我想将前置闪光灯设置为自动闪光灯,因此前置摄像头不支持闪光灯,所以我必须将一个 View 设置为白色,以便它作为闪光灯使用,现在我的问题是如果用户设置了怎么办闪光模式自动?当我必须显示 Flash V
我有一个表,其中每隔一个表行都有一个类名“hideme”。在我制作的 css 文件中 .hideme { display:none} 隐藏行包含一个密码字段和一个按钮。在任何给定时间只能显示一个隐藏行
我正在尝试使用 css 切换复选框,使用开/关图像进行切换。但是它并没有发生,fiddle . I agree input[type=checkbox] { display:non
我正在为智能手机编写一个网站。我使用 javascript: navigator.geolocation.getCurrentPosition 来获取位置。 尽管如此,在执行此功能之前,我需要检测 G
如何在我的 Android 应用程序中以编程方式设置数据漫游开/关? 最佳答案 提前为重新打开一个死帖而道歉,但我已经通过调用这个可执行文件设法实现了它: su -c settings put glo
我正在用 java 编程,但我也可以采用 C++(甚至伪)代码,没问题。这是我的意思: 我有一个类似播放列表的东西,例如 List lsMyPlaylist .现在我想给用户洗牌的机会,然后再回到有序
我正在寻找最好的、最具可扩展性的方式来跟踪大量的开/关。开/关适用于项目,编号从 1 到大约 6000 万。 (在我的例子中,开/关是成员(member)的书是否被编入索引,这是一个单独的过程。) 开
我发现下面的代码可以以被动的方式做到这一点。 context.registerReceiver(this.ScreenOffReceiver, new IntentFilter(Intent.ACTI
我有一个脚本,我定期运行以使用 Applescript 打开/关闭灰度。它在 High Sierra 上运行良好,但当我在 Mojave 使用它时抛出异常。 tell application "Sys
如果我启动一个内联 Matplotlib 的 IPython Notebook,有没有办法随后绘制一个图形,以便它以“标准”、非内联的方式显示,而无需在没有内联命令的情况下重新加载笔记本? 我希望能够
如何使用Android中的CheckBoxPreference切换整个系统的声音,振动,数据连接和wifi? 我想在我的应用程序中正在运行 Activity 时禁用这些功能。 最佳答案 我想到了。 在
我想在我的网站上创建一个维护模式,我想放置一个只有管理员才能看到的按钮来打开/关闭维护模式。 这允许管理员继续查看网络,但其他访问者则不能。 我读过有关 catchAllRequest 的内容,创建一
如何检测客户端或服务器端 (ASP.NET) 的浏览器缓存设置。基本上尝试检测用户浏览器是否打开或关闭了缓存。如果关闭,我想将他们重定向到一个包含错误消息的页面,告诉他们打开它。这可能吗? 最佳答案
我是一名优秀的程序员,十分优秀!