问题标签 [kubernetes-security]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
authentication - 带证书的 Kubernetes 身份验证
我正在尝试使用证书对本地托管的 Kubernetes 集群(v1.6.4)进行身份验证。这涉及为 Jenkins 使用 Kubernetes 插件的上下文。
我正在遵循Kubernetes-plugin README文件中的 Minikube 指南,该文件已适应我的场景:
将客户端证书转换为 PKCS:
/li>在 Jenkins 中,使用证书创建凭据
Kind
:Certificate
Certificate
:Upload PKCS#12 certificate
并上传文件kubernetes.pfx
Password
:(jenkins
在证书创建期间指定)
Manage Jenkins
->Add new cloud
->Kubernetes
Kubernetes URL
:https://10.179.1.121:6443
(作为输出kubectl config view
)Kubernetes server certificate key
: 粘贴内容/etc/kubernetes/pki/ca.crt
。Disable https certificate check
:检查,因为测试设置没有签名证书Kubernetes Namespace
: 都试过default
了kubernetes-plugin
Credentials
:(CN=kube-apiserver
即上面创建的凭据)
现在,当我单击 时Test Connection
,这是 Jenkins Web UI 中显示的错误消息:
连接到https://10.179.1.121:6443时出错:执行失败:GET at:https ://10.179.1.121:6443/api/v1/namespaces/kubernetes-plugin/pods 。消息:未经授权。
Jenkins 日志显示此消息:
2017 年 9 月 5 日上午 10:22:03 io.fabric8.kubernetes.client.Config tryServiceAccount
警告:从 [/var/run/secrets/kubernetes.io/serviceaccount/token] 读取服务帐户令牌时出错。无视。
不幸的是,文档主要限于在 Minikube 和 Google Cloud Engine 上运行的 Kubernetes,但我看不出前者与本地托管的 Kubernetes 集群之间存在概念上的差异。
以下 Curl 测试调用会导致非常不同的错误消息:
更详细:
我还设置了一个 ServiceAccount:
这个问题涉及一个相关问题,建议使用 ServiceAccount 或证书,但后一种方法的答案缺少有关如何将 RBAC 配置文件与该证书绑定的详细信息。有关身份验证的Kubernetes 文档似乎并未涵盖此用例。
kubernetes - 连接到 pod 中其他容器的 shell 终端
当我在 pod/pod 模板中定义多个容器时,比如一个容器正在运行agent
,另一个容器php-fpm
,它们如何相互访问?我需要通过 shellagent container
连接,并且需要通过.php-fpm
agent container
根据我的理解,我们可以打包kubectl
成agent container
并kubectl exec -it <container id> sh
用来连接到容器中。但我不想Agent container
拥有比使用 is 连接到目标容器更多的特权php-fpm
。
有没有更好的方法可以通过 shellagent container
连接并以php-fpm
交互方式执行命令?
另外,由于以下错误,我在使用时没有成功kubectl
从容器运行minikube
kubernetes - 将 IP 列入白名单以使用 Kubernetes 入口 Istio 访问部署
我正在尝试将 IP 列入白名单以访问我的 Kubernetes 集群内的部署。
我在网上找了一些关于这个的文档,但我只找到了
入口以授予对特定 IP 范围的访问权限。但是,我仍然无法隔离部署。
这是入口配置 YAML 文件:
我可以从我的白名单 IP 和手机访问部署(配置中未列入白名单的不同 IP)
有没有人使用 ingress 和 Istio 解决过同样的问题?
任何帮助、提示、文档或替代配置将不胜感激。
linux - 使用 Ansible 在 Kubernetes 集群中实现证书轮换功能
如何在 kubernetes 集群的不同层上使用 Ansible 进行证书轮换?
在我们使用舰队之前,现在迁移到 Kubernetes。
kubernetes - Kubernetes API proxy for HTTPS endpoints
Kubernetes surfaces an API proxy, which allows querying the internal services via eg: https://myhost.com/api/v1/proxy/namespaces/kube-system/services/kubernetes-dashboard/
This is all well, and good. However, for security & compliance reasons, all of our services expose an HTTPS endpoint. Attempting to access them by going to https://myhost/api/v1/proxy/namespaces/default/services/myhttpsservice:3000/ results in
Because the endpoint, 100.96.29.113:3000 is in fact https.
Is there any way to configure the proxy to apply SSL to specific service endpoints?
(Edit: If this is not currently possible, a relevant github issue link for tracking the feature request is also acceptable answer until it will be)
ssl - 使用 cfssl 和 kubernetes 生成 CA 证书和私钥时出错
我正在使用cfssl生成 CSR。
我有以下 json 格式
在下一步中,通过运行以下命令生成 CSR yaml blob 并将其发送到 apiserver:
我正在关注此链接 管理集群中的 TLS 证书
kubernetes - Kubernetes webhook 用户客户端证书配置是什么意思?
我需要为 Kubernetes 实现一个自定义的身份验证和授权模块。这必须通过网络挂钩来完成。
身份验证和授权webhook的文档描述了 API 服务器需要启动的配置文件。
对于身份验证和授权,配置文件看起来相同,如下所示:
我可以看到该clusters
部分指的是远程服务,即它定义了 webhook,从而回答了 API 服务器需要回答的问题:“当需要 authn/authz 决策时,要命中的 URL 端点是什么,当我通过 HTTPS 连接,谁是 Webhook 的 TLS 证书的 CA 机构,以便我知道我可以信任远程 Webhook?”
我不确定该users
部分。client-certificate
和client-key
字段的目的是什么?文件中的注释说“要使用的 webhook 插件的证书”,但是由于这个配置文件是给 API 服务器的,而不是 web 钩子,我不明白这是什么意思。这是一个允许 webhook 服务验证 API 服务器将使用它启动的连接的证书吗?即客户端证书需要进入 webhook 服务器的信任库?
这两个假设都正确吗?
kubernetes - 是否可以自定义 Kubernetes 服务帐户令牌的创建和存储?
是否可以自定义创建 Kubernetes 服务帐户的方式?
一旦创建,是否可以指定它的存储方式?
如果可能的话,我想避免将令牌存储为秘密,因为我希望它们存储在 Kubernetes 之外。
kubernetes - What are the Kubernetes API resources (within ResourceAttributes) and verbs?
I'm wanting to understand what authorisation requests are possible when implementing a custom webhook. The docs describe a SubjectAccessReview that references a SubjectAccessReviewSpec that references a ResourceAttributes object that references a string field called resource
, which is described as:
Resource is one of the existing resource types. "*" means all.
Where is the list of all resources and what resources are defined?
What are the verbs that can appear in the request?
kubernetes - 如何使用 RBAC 控制对某类秘密资源的访问?
在我的 k8s 集群中,下面列出了一些秘密资源。
$kubectl 获取秘密 -n istio-system
NAME TYPE
default-token-4wwkb kubernetes.io/service-account-token
istio-ca-secret istio.io/ca-root
istio-ca-service-account-token-rl4xm kubernetes.io/service-account-token
istio-egress-service-account-token-vbfwf kubernetes.io/service-account-token
istio-ingress-certs kubernetes.io/tls
istio-ingress-service-account-token-kwr85 kubernetes.io/service-account-token
istio-mixer-service-account-token-29qbb kubernetes.io/service-account-token
istio-pilot-service-account-token-t6kmf kubernetes.io/service-account-token
istio.default istio.io/key-and-cert
istio.istio-ca-service-account istio.io/key-and-cert
istio.istio-egress-service-account istio.io/key-and-cert
istio.istio-ingress-service-account istio.io/key-and-cert
istio.istio-mixer-service-account istio.io/key-and-cert
istio.istio-pilot-service-account istio.io/key-and-cert
istio.test-istio-sa istio.io/key-and-cert
test-istio-sa-token-4zm9k kubernetes.io/service-account-token
现在想用rbac控制一个service account test-istio-sa,这样test-istio-sa只能访问kubernetes.io/service-account-token类型的所有secret,比如istio-ca-service- account-token-rl4xm 和 istio-ingress-service-account-token-kwr85。
我创建了一个角色 kube-sa-token-reader,并将其绑定到服务帐户 test-istio-sa。
但它似乎没有按预期工作。
$ kubectl auth can-i get secret/kubernetes.io/service-account-token -n istio-system --as system:serviceaccount:istio-system:test-istio-sa
no - Unknown user "system:serviceaccount:istio-system:test-istio-sa"