Gitlab CI Pipeline: Cannot create pods in the namespace
I have a kubernetes cluster (rancherOS & RKE) that has a running gitlab runner pod.
Connection to my GitLab instance works fine.
If I activate the pipeline, it directly fails with this error:
Running with gitlab-runner 11.4.2 (cf91d5e1)
on Kubernetes Runner e5e25776
Using Kubernetes namespace: gitlab-managed-apps
Using Kubernetes executor with image ubuntu:latest ...
ERROR: Job failed (system failure): pods is forbidden: User "system:serviceaccount:gitlab-managed-apps:default" cannot create pods in the namespace "gitlab-managed-apps"
This here is my gitlab-runner deployment yaml:
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: gitlab-runner
namespace: gitlab-managed-apps
spec:
replicas: 1
selector:
matchLabels:
name: gitlab-runner
template:
metadata:
labels:
name: gitlab-runner
spec:
containers:
- args:
- run
image: gitlab/gitlab-runner:latest
imagePullPolicy: Always
name: gitlab-runner
securityContext:
privileged: true
volumeMounts:
- mountPath: /etc/gitlab-runner
name: config
- mountPath: /etc/ssl/certs
name: cacerts
readOnly: true
restartPolicy: Always
volumes:
- configMap:
name: gitlab-runner
name: config
- hostPath:
path: /usr/share/ca-certificates/mozilla
name: cacerts
hostNetwork: true
I tried to add a security context with the parameter "privileged: true" but that does not help..
Has anyone an idea on how to grant the gitlab-runner deployment the right permission to create other pods in the namespace "gitlab-managed-apps"?
Thanks a lot :)
kubernetes continuous-integration gitlab pipeline
add a comment |
I have a kubernetes cluster (rancherOS & RKE) that has a running gitlab runner pod.
Connection to my GitLab instance works fine.
If I activate the pipeline, it directly fails with this error:
Running with gitlab-runner 11.4.2 (cf91d5e1)
on Kubernetes Runner e5e25776
Using Kubernetes namespace: gitlab-managed-apps
Using Kubernetes executor with image ubuntu:latest ...
ERROR: Job failed (system failure): pods is forbidden: User "system:serviceaccount:gitlab-managed-apps:default" cannot create pods in the namespace "gitlab-managed-apps"
This here is my gitlab-runner deployment yaml:
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: gitlab-runner
namespace: gitlab-managed-apps
spec:
replicas: 1
selector:
matchLabels:
name: gitlab-runner
template:
metadata:
labels:
name: gitlab-runner
spec:
containers:
- args:
- run
image: gitlab/gitlab-runner:latest
imagePullPolicy: Always
name: gitlab-runner
securityContext:
privileged: true
volumeMounts:
- mountPath: /etc/gitlab-runner
name: config
- mountPath: /etc/ssl/certs
name: cacerts
readOnly: true
restartPolicy: Always
volumes:
- configMap:
name: gitlab-runner
name: config
- hostPath:
path: /usr/share/ca-certificates/mozilla
name: cacerts
hostNetwork: true
I tried to add a security context with the parameter "privileged: true" but that does not help..
Has anyone an idea on how to grant the gitlab-runner deployment the right permission to create other pods in the namespace "gitlab-managed-apps"?
Thanks a lot :)
kubernetes continuous-integration gitlab pipeline
add a comment |
I have a kubernetes cluster (rancherOS & RKE) that has a running gitlab runner pod.
Connection to my GitLab instance works fine.
If I activate the pipeline, it directly fails with this error:
Running with gitlab-runner 11.4.2 (cf91d5e1)
on Kubernetes Runner e5e25776
Using Kubernetes namespace: gitlab-managed-apps
Using Kubernetes executor with image ubuntu:latest ...
ERROR: Job failed (system failure): pods is forbidden: User "system:serviceaccount:gitlab-managed-apps:default" cannot create pods in the namespace "gitlab-managed-apps"
This here is my gitlab-runner deployment yaml:
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: gitlab-runner
namespace: gitlab-managed-apps
spec:
replicas: 1
selector:
matchLabels:
name: gitlab-runner
template:
metadata:
labels:
name: gitlab-runner
spec:
containers:
- args:
- run
image: gitlab/gitlab-runner:latest
imagePullPolicy: Always
name: gitlab-runner
securityContext:
privileged: true
volumeMounts:
- mountPath: /etc/gitlab-runner
name: config
- mountPath: /etc/ssl/certs
name: cacerts
readOnly: true
restartPolicy: Always
volumes:
- configMap:
name: gitlab-runner
name: config
- hostPath:
path: /usr/share/ca-certificates/mozilla
name: cacerts
hostNetwork: true
I tried to add a security context with the parameter "privileged: true" but that does not help..
Has anyone an idea on how to grant the gitlab-runner deployment the right permission to create other pods in the namespace "gitlab-managed-apps"?
Thanks a lot :)
kubernetes continuous-integration gitlab pipeline
I have a kubernetes cluster (rancherOS & RKE) that has a running gitlab runner pod.
Connection to my GitLab instance works fine.
If I activate the pipeline, it directly fails with this error:
Running with gitlab-runner 11.4.2 (cf91d5e1)
on Kubernetes Runner e5e25776
Using Kubernetes namespace: gitlab-managed-apps
Using Kubernetes executor with image ubuntu:latest ...
ERROR: Job failed (system failure): pods is forbidden: User "system:serviceaccount:gitlab-managed-apps:default" cannot create pods in the namespace "gitlab-managed-apps"
This here is my gitlab-runner deployment yaml:
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: gitlab-runner
namespace: gitlab-managed-apps
spec:
replicas: 1
selector:
matchLabels:
name: gitlab-runner
template:
metadata:
labels:
name: gitlab-runner
spec:
containers:
- args:
- run
image: gitlab/gitlab-runner:latest
imagePullPolicy: Always
name: gitlab-runner
securityContext:
privileged: true
volumeMounts:
- mountPath: /etc/gitlab-runner
name: config
- mountPath: /etc/ssl/certs
name: cacerts
readOnly: true
restartPolicy: Always
volumes:
- configMap:
name: gitlab-runner
name: config
- hostPath:
path: /usr/share/ca-certificates/mozilla
name: cacerts
hostNetwork: true
I tried to add a security context with the parameter "privileged: true" but that does not help..
Has anyone an idea on how to grant the gitlab-runner deployment the right permission to create other pods in the namespace "gitlab-managed-apps"?
Thanks a lot :)
kubernetes continuous-integration gitlab pipeline
kubernetes continuous-integration gitlab pipeline
asked Nov 20 '18 at 13:16
user7436888user7436888
3215
3215
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
In your deployment yaml you didn't add spec.template.spec.serviceAccountName
, which means it uses the default serviceaccount named default
in your deployment namespace named gitlab-managed-apps
. And it has no rbac
rule to create pods according to the error you specified.
For details, see https://kubernetes.io/docs/reference/access-authn-authz/rbac/.
There are more than one way to resolve this. Here is one:
First create a rbac rule and bind it to a serviceaccount. Bellow is an example:
apiVersion: v1
kind: ServiceAccount
metadata:
name: gitlab
namespace: gitlab-managed-apps
---
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
namespace: gitlab-managed-apps
name: gitlab
rules:
- apiGroups: [""] # "" indicates the core API group
resources: ["pods"]
verbs: ["create"]
---
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: gitlab
namespace: gitlab-managed-apps
subjects:
- kind: ServiceAccount
name: gitlab # Name is case sensitive
apiGroup: ""
roleRef:
kind: Role #this must be Role or ClusterRole
name: gitlab # this must match the name of the Role or ClusterRole you wish to bind to
apiGroup: rbac.authorization.k8s.io
Then edit your deployment yaml to add this serviceaccount
:
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: gitlab-runner
namespace: gitlab-managed-apps
spec:
replicas: 1
selector:
matchLabels:
name: gitlab-runner
template:
metadata:
labels:
name: gitlab-runner
spec:
serviceAccountName: gitlab
containers:
- args:
- run
image: gitlab/gitlab-runner:latest
imagePullPolicy: Always
name: gitlab-runner
securityContext:
privileged: true
volumeMounts:
- mountPath: /etc/gitlab-runner
name: config
- mountPath: /etc/ssl/certs
name: cacerts
readOnly: true
restartPolicy: Always
volumes:
- configMap:
name: gitlab-runner
name: config
- hostPath:
path: /usr/share/ca-certificates/mozilla
name: cacerts
hostNetwork: true
Then deploy your gitlab instances and other things those you need.
What if I don't have permissions to create a role in cloud account i.e. GCP. Will this solution work?
– Dipen Dedania
Nov 21 '18 at 12:00
you definitely need this permission
– VKR
Nov 27 '18 at 16:12
Definitely, @VKR is right. If one has no permission to create a role then he/she can't do anything.
– Shudipta Sharma
Nov 27 '18 at 17:06
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53393853%2fgitlab-ci-pipeline-cannot-create-pods-in-the-namespace%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
In your deployment yaml you didn't add spec.template.spec.serviceAccountName
, which means it uses the default serviceaccount named default
in your deployment namespace named gitlab-managed-apps
. And it has no rbac
rule to create pods according to the error you specified.
For details, see https://kubernetes.io/docs/reference/access-authn-authz/rbac/.
There are more than one way to resolve this. Here is one:
First create a rbac rule and bind it to a serviceaccount. Bellow is an example:
apiVersion: v1
kind: ServiceAccount
metadata:
name: gitlab
namespace: gitlab-managed-apps
---
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
namespace: gitlab-managed-apps
name: gitlab
rules:
- apiGroups: [""] # "" indicates the core API group
resources: ["pods"]
verbs: ["create"]
---
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: gitlab
namespace: gitlab-managed-apps
subjects:
- kind: ServiceAccount
name: gitlab # Name is case sensitive
apiGroup: ""
roleRef:
kind: Role #this must be Role or ClusterRole
name: gitlab # this must match the name of the Role or ClusterRole you wish to bind to
apiGroup: rbac.authorization.k8s.io
Then edit your deployment yaml to add this serviceaccount
:
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: gitlab-runner
namespace: gitlab-managed-apps
spec:
replicas: 1
selector:
matchLabels:
name: gitlab-runner
template:
metadata:
labels:
name: gitlab-runner
spec:
serviceAccountName: gitlab
containers:
- args:
- run
image: gitlab/gitlab-runner:latest
imagePullPolicy: Always
name: gitlab-runner
securityContext:
privileged: true
volumeMounts:
- mountPath: /etc/gitlab-runner
name: config
- mountPath: /etc/ssl/certs
name: cacerts
readOnly: true
restartPolicy: Always
volumes:
- configMap:
name: gitlab-runner
name: config
- hostPath:
path: /usr/share/ca-certificates/mozilla
name: cacerts
hostNetwork: true
Then deploy your gitlab instances and other things those you need.
What if I don't have permissions to create a role in cloud account i.e. GCP. Will this solution work?
– Dipen Dedania
Nov 21 '18 at 12:00
you definitely need this permission
– VKR
Nov 27 '18 at 16:12
Definitely, @VKR is right. If one has no permission to create a role then he/she can't do anything.
– Shudipta Sharma
Nov 27 '18 at 17:06
add a comment |
In your deployment yaml you didn't add spec.template.spec.serviceAccountName
, which means it uses the default serviceaccount named default
in your deployment namespace named gitlab-managed-apps
. And it has no rbac
rule to create pods according to the error you specified.
For details, see https://kubernetes.io/docs/reference/access-authn-authz/rbac/.
There are more than one way to resolve this. Here is one:
First create a rbac rule and bind it to a serviceaccount. Bellow is an example:
apiVersion: v1
kind: ServiceAccount
metadata:
name: gitlab
namespace: gitlab-managed-apps
---
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
namespace: gitlab-managed-apps
name: gitlab
rules:
- apiGroups: [""] # "" indicates the core API group
resources: ["pods"]
verbs: ["create"]
---
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: gitlab
namespace: gitlab-managed-apps
subjects:
- kind: ServiceAccount
name: gitlab # Name is case sensitive
apiGroup: ""
roleRef:
kind: Role #this must be Role or ClusterRole
name: gitlab # this must match the name of the Role or ClusterRole you wish to bind to
apiGroup: rbac.authorization.k8s.io
Then edit your deployment yaml to add this serviceaccount
:
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: gitlab-runner
namespace: gitlab-managed-apps
spec:
replicas: 1
selector:
matchLabels:
name: gitlab-runner
template:
metadata:
labels:
name: gitlab-runner
spec:
serviceAccountName: gitlab
containers:
- args:
- run
image: gitlab/gitlab-runner:latest
imagePullPolicy: Always
name: gitlab-runner
securityContext:
privileged: true
volumeMounts:
- mountPath: /etc/gitlab-runner
name: config
- mountPath: /etc/ssl/certs
name: cacerts
readOnly: true
restartPolicy: Always
volumes:
- configMap:
name: gitlab-runner
name: config
- hostPath:
path: /usr/share/ca-certificates/mozilla
name: cacerts
hostNetwork: true
Then deploy your gitlab instances and other things those you need.
What if I don't have permissions to create a role in cloud account i.e. GCP. Will this solution work?
– Dipen Dedania
Nov 21 '18 at 12:00
you definitely need this permission
– VKR
Nov 27 '18 at 16:12
Definitely, @VKR is right. If one has no permission to create a role then he/she can't do anything.
– Shudipta Sharma
Nov 27 '18 at 17:06
add a comment |
In your deployment yaml you didn't add spec.template.spec.serviceAccountName
, which means it uses the default serviceaccount named default
in your deployment namespace named gitlab-managed-apps
. And it has no rbac
rule to create pods according to the error you specified.
For details, see https://kubernetes.io/docs/reference/access-authn-authz/rbac/.
There are more than one way to resolve this. Here is one:
First create a rbac rule and bind it to a serviceaccount. Bellow is an example:
apiVersion: v1
kind: ServiceAccount
metadata:
name: gitlab
namespace: gitlab-managed-apps
---
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
namespace: gitlab-managed-apps
name: gitlab
rules:
- apiGroups: [""] # "" indicates the core API group
resources: ["pods"]
verbs: ["create"]
---
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: gitlab
namespace: gitlab-managed-apps
subjects:
- kind: ServiceAccount
name: gitlab # Name is case sensitive
apiGroup: ""
roleRef:
kind: Role #this must be Role or ClusterRole
name: gitlab # this must match the name of the Role or ClusterRole you wish to bind to
apiGroup: rbac.authorization.k8s.io
Then edit your deployment yaml to add this serviceaccount
:
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: gitlab-runner
namespace: gitlab-managed-apps
spec:
replicas: 1
selector:
matchLabels:
name: gitlab-runner
template:
metadata:
labels:
name: gitlab-runner
spec:
serviceAccountName: gitlab
containers:
- args:
- run
image: gitlab/gitlab-runner:latest
imagePullPolicy: Always
name: gitlab-runner
securityContext:
privileged: true
volumeMounts:
- mountPath: /etc/gitlab-runner
name: config
- mountPath: /etc/ssl/certs
name: cacerts
readOnly: true
restartPolicy: Always
volumes:
- configMap:
name: gitlab-runner
name: config
- hostPath:
path: /usr/share/ca-certificates/mozilla
name: cacerts
hostNetwork: true
Then deploy your gitlab instances and other things those you need.
In your deployment yaml you didn't add spec.template.spec.serviceAccountName
, which means it uses the default serviceaccount named default
in your deployment namespace named gitlab-managed-apps
. And it has no rbac
rule to create pods according to the error you specified.
For details, see https://kubernetes.io/docs/reference/access-authn-authz/rbac/.
There are more than one way to resolve this. Here is one:
First create a rbac rule and bind it to a serviceaccount. Bellow is an example:
apiVersion: v1
kind: ServiceAccount
metadata:
name: gitlab
namespace: gitlab-managed-apps
---
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
namespace: gitlab-managed-apps
name: gitlab
rules:
- apiGroups: [""] # "" indicates the core API group
resources: ["pods"]
verbs: ["create"]
---
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: gitlab
namespace: gitlab-managed-apps
subjects:
- kind: ServiceAccount
name: gitlab # Name is case sensitive
apiGroup: ""
roleRef:
kind: Role #this must be Role or ClusterRole
name: gitlab # this must match the name of the Role or ClusterRole you wish to bind to
apiGroup: rbac.authorization.k8s.io
Then edit your deployment yaml to add this serviceaccount
:
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: gitlab-runner
namespace: gitlab-managed-apps
spec:
replicas: 1
selector:
matchLabels:
name: gitlab-runner
template:
metadata:
labels:
name: gitlab-runner
spec:
serviceAccountName: gitlab
containers:
- args:
- run
image: gitlab/gitlab-runner:latest
imagePullPolicy: Always
name: gitlab-runner
securityContext:
privileged: true
volumeMounts:
- mountPath: /etc/gitlab-runner
name: config
- mountPath: /etc/ssl/certs
name: cacerts
readOnly: true
restartPolicy: Always
volumes:
- configMap:
name: gitlab-runner
name: config
- hostPath:
path: /usr/share/ca-certificates/mozilla
name: cacerts
hostNetwork: true
Then deploy your gitlab instances and other things those you need.
edited Nov 20 '18 at 13:52
answered Nov 20 '18 at 13:28
Shudipta SharmaShudipta Sharma
1,185413
1,185413
What if I don't have permissions to create a role in cloud account i.e. GCP. Will this solution work?
– Dipen Dedania
Nov 21 '18 at 12:00
you definitely need this permission
– VKR
Nov 27 '18 at 16:12
Definitely, @VKR is right. If one has no permission to create a role then he/she can't do anything.
– Shudipta Sharma
Nov 27 '18 at 17:06
add a comment |
What if I don't have permissions to create a role in cloud account i.e. GCP. Will this solution work?
– Dipen Dedania
Nov 21 '18 at 12:00
you definitely need this permission
– VKR
Nov 27 '18 at 16:12
Definitely, @VKR is right. If one has no permission to create a role then he/she can't do anything.
– Shudipta Sharma
Nov 27 '18 at 17:06
What if I don't have permissions to create a role in cloud account i.e. GCP. Will this solution work?
– Dipen Dedania
Nov 21 '18 at 12:00
What if I don't have permissions to create a role in cloud account i.e. GCP. Will this solution work?
– Dipen Dedania
Nov 21 '18 at 12:00
you definitely need this permission
– VKR
Nov 27 '18 at 16:12
you definitely need this permission
– VKR
Nov 27 '18 at 16:12
Definitely, @VKR is right. If one has no permission to create a role then he/she can't do anything.
– Shudipta Sharma
Nov 27 '18 at 17:06
Definitely, @VKR is right. If one has no permission to create a role then he/she can't do anything.
– Shudipta Sharma
Nov 27 '18 at 17:06
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53393853%2fgitlab-ci-pipeline-cannot-create-pods-in-the-namespace%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown