--runtime-config
.dev
中的任何实体都可以使用该YAML文件访问名称空间dev
中的任何内容。注意:此链接的内容已经更改,请参见我在问题底部工作时获得的YAML文件。-subj“/cn=example-dev@kubernetes.click/o=dev”
.运行时会出现以下错误:kubectl-v8--kubeconfig=/tmp/dev-kube-config.yml create-f/tmp/busybox.yml
:
I1219 16:12:37.584657 44323 loader.go:354] Config loaded from file /tmp/dev-kube-config.yml
I1219 16:12:37.585953 44323 round_trippers.go:296] GET https://api.kubernetes.click/api
I1219 16:12:37.585968 44323 round_trippers.go:303] Request Headers:
I1219 16:12:37.585983 44323 round_trippers.go:306] Accept: application/json, */*
I1219 16:12:37.585991 44323 round_trippers.go:306] User-Agent: kubectl/v1.5.1+82450d0 ( darwin/amd64) kubernetes/82450d0
I1219 16:12:38.148994 44323 round_trippers.go:321] Response Status: 403 Forbidden in 562 milliseconds
I1219 16:12:38.149056 44323 round_trippers.go:324] Response Headers:
I1219 16:12:38.149070 44323 round_trippers.go:327] Content-Type: text/plain; charset=utf- 8
I1219 16:12:38.149081 44323 round_trippers.go:327] Content-Length: 17
I1219 16:12:38.149091 44323 round_trippers.go:327] Date: Tue, 20 Dec 2016 00:12:38 GMT
I1219 16:12:38.149190 44323 request.go:904] Response Body: Forbidden: "/api"
I1219 16:12:38.149249 44323 request.go:995] Response Body: "Forbidden: \"/api\""
I1219 16:12:38.149567 44323 request.go:1151] body was not decodable (unable to check for Status): Object 'Kind' is missing in 'Forbidden: "/api"'
...
I1219 16:12:38.820672 44323 round_trippers.go:296] GET https://api.kubernetes. click/swaggerapi/api/v1
I1219 16:12:38.820702 44323 round_trippers.go:303] Request Headers:
I1219 16:12:38.820717 44323 round_trippers.go:306] User-Agent: kubectl/v1.5.1+82450d0 ( darwin/amd64) kubernetes/82450d0
I1219 16:12:38.820731 44323 round_trippers.go:306] Accept: application/json, */*
I1219 16:12:38.902256 44323 round_trippers.go:321] Response Status: 403 Forbidden in 81 milliseconds
I1219 16:12:38.902306 44323 round_trippers.go:324] Response Headers:
I1219 16:12:38.902327 44323 round_trippers.go:327] Content-Type: text/plain; charset=utf- 8
I1219 16:12:38.902345 44323 round_trippers.go:327] Content-Length: 31
I1219 16:12:38.902363 44323 round_trippers.go:327] Date: Tue, 20 Dec 2016 00:12:38 GMT
I1219 16:12:38.902456 44323 request.go:904] Response Body: Forbidden: "/swaggerapi/api/v1"
I1219 16:12:38.902512 44323 request.go:995] Response Body: "Forbidden: \"/swaggerapi/api/v1\""
F1219 16:12:38.903025 44323 helpers.go:116] error: error validating "/tmp/busybox.yml": error validating data: the server does not allow access to the requested resource; if you choose to ignore these errors, turn validation off with --validate=false
应在dev
命名空间中创建busybox pod。
>
$kubectl版本
Client Version: version.Info{Major:"1", Minor:"5", GitVersion:"v1.5.1+82450d0", GitCommit:"82450d03cb057bab0950214ef122b67c83fb11df", GitTreeState:"not a git tree", BuildDate:"2016-12-14T04:09:31Z", GoVersion:"go1.7.4", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"4", GitVersion:"v1.4.6", GitCommit:"e569a27d02001e343cb68086bc06d47804f62af6", GitTreeState:"clean", BuildDate:"2016-11-12T05:16:27Z", GoVersion:"go1.6.3", Compiler:"gc", Platform:"linux/amd64"}
GitHub问题:https://GitHub.com/kubernetes/kubernetes/issues/38997
编辑:基于答案和评论的工作解决方案
根据Jordan在下面的回答,我升级到Kubernetes V1.5.1,然后获得了以下两个YAML文件来构造命名空间和所有正确的RBAC资源,以便一切都按需要工作:
system-access.yml
(因为开箱即用的集群角色和集群角色绑定似乎不起作用):
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1alpha1
metadata:
name: system:node--kubelet
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: system:node
subjects:
- kind: User
name: kubelet
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1alpha1
metadata:
name: cluster-admin--kube-system:default
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-admin
subjects:
- kind: ServiceAccount
name: default
namespace: kube-system
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1alpha1
metadata:
name: system:node-proxier--kube-proxy
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: system:node-proxier
subjects:
- kind: User
name: kube-proxy
dev-access.yml
:
kind: Namespace
apiVersion: v1
metadata:
name: dev
---
kind: Role
apiVersion: rbac.authorization.k8s.io/v1alpha1
metadata:
namespace: dev
name: dev-all
rules:
- apiGroups: ["*"]
resources: ["*"]
verbs: ["*"]
---
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1alpha1
metadata:
name: dev-role-dev-all-members
namespace: dev
subjects:
- kind: Group
name: dev
- kind: Group
name: system:serviceaccounts:dev
roleRef:
kind: Role
name: dev-all
apiGroup: "rbac.authorization.k8s.io"
首先,您需要允许对kubectl用于API发现和验证的URL的访问(swagger,API组和资源类型的列表,等等)。
最简单的方法是加载默认的引导集群角色和集群角色绑定:
kubectl create -f https://raw.githubusercontent.com/kubernetes/kubernetes/master/plugin/pkg/auth/authorizer/rbac/bootstrappolicy/testdata/cluster-roles.yaml
kubectl create -f https://raw.githubusercontent.com/kubernetes/kubernetes/master/plugin/pkg/auth/authorizer/rbac/bootstrappolicy/testdata/cluster-role-bindings.yaml
这将创建一个system:discovery
ClusterRole,并将所有用户(经过身份验证和未经身份验证)绑定到它,允许他们访问swagger和API组信息。
我在一个多租户节点应用程序中工作,我知道要在Kubernetes中创建一个新的命名空间,可以运行一个kubectl命令,如下所示:
问题内容: 该文档仅提及嵌套类型,但尚不清楚它们是否可用作命名空间。我还没有发现任何有关命名空间的明确提及。 问题答案: 在苹果开发论坛中, SevenTenEleven 回答了: 命名空间不是按文件的;它们是基于目标的(基于“产品模块名称”构建设置)。因此,您最终将得到如下结果: 所有Swift声明都被认为是某个模块的一部分,因此即使您说“ ”(是的,它仍然存在),您也会得到Swift认为的“
问题内容: 我尝试在 Eclipse 中使用,尽管从 IntelliSense 和 Package Explorer 都可以看出,该命名空间不存在。 所以我想除了默认加载的包之外,我还必须加载其他包(在Java中称它们为库吗?)。 这是我当前的设置:( 链接无效 ) 问题答案: 您需要将Apache commons jar文件添加到项目中。您可以从此处选择所需的jar- http ://commo
为什么using指令在包含在匿名命名空间中时表现得好像出现在全局范围?
我想做的是能够从客户机创建一个房间,但好像它是一个对象。例如:我有一个名为“room”的类,这个类实现了3个事件,所以当你创建一个新的room时,你可以在每个事件中触发这些事件。这可能吗?以下是我的服务器代码:
我在默认命名空间中创建了一个serviceaccount(dm sa),并在clusterRole(绑定到PodSecurityPolicy)和clusterRoleBinding中使用了这个serviceaccount。接下来,在部署yaml(将在名称空间“dm”中运行)中,我在模板:spec下指定了serviceAccount:dm和serviceAccountName:default。这样,