Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<username>-che as default namespace #156

Closed
wants to merge 15 commits into from
Closed

Conversation

AndrienkoAleksandr
Copy link
Contributor

Referenced issue
issue: eclipse-che/che#15493

What does this PR do?
Continue work started #137 :

  • don't create che-workspace SA
  • check what namespace we're using for workspaces (workspaceNamespaceDefault)
    • if it is different than che-operator is deployed to, create all ClusterRoles and ClusterRoleBindings needed to create new namespaces and to create workspaces in them
    • if it is same as che-operator's namespace, create just Role and RoleBinding needed to manage workspaces in same namespace
  • if oauth is enabled, just create che sa with no granted permissions
  • finalize cluster roles and cluster role bindings created by che-operator for Che server
  • make working Che server property CHE_INFRA_KUBERNETES_CLUSTER__ROLE__NAME

Related pr(s)
che-incubator/chectl#469

TODO:

  • test and fix permissions for k8s (currently it works for openshift)
  • test with OS Oauth. PR does not grant any permissions for che sa
  • check chectl
  • test installation with olm

sparkoo and others added 10 commits December 3, 2019 16:19
… to che serviceaccount

Signed-off-by: Michal Vala <mvala@redhat.com>
Signed-off-by: Michal Vala <mvala@redhat.com>
…amespaces

Signed-off-by: Michal Vala <mvala@redhat.com>
…rent namespace than che

Signed-off-by: Michal Vala <mvala@redhat.com>
Signed-off-by: Michal Vala <mvala@redhat.com>
Signed-off-by: Michal Vala <mvala@redhat.com>
Fix failing workspace start due 'update' namespace permission. Handle todo about saving Che worksapce cluster role property to config map. Rename che cluster role to che-manage-namespaces

Signed-off-by: Oleksandr Andriienko <oandriie@redhat.com>
Signed-off-by: Oleksandr Andriienko <oandriie@redhat.com>
Copy link
Member

@sparkoo sparkoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

few nitpicks

deploy_k8s.sh Outdated
# sometimes the operator cannot get CRD right away
sleep 2

# uncomment if you need Login with OpenShift
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is irrelevant here

deploy_k8s.sh Outdated

BASE_DIR=$(cd "$(dirname "$0")"; pwd)

kubectl apply -f "${BASE_DIR}"/deploy/service_account.yaml -n che
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be nice if script accepts one arg with namespace, defaulting to che

}

// this binding is needed to manage che workspaces out of che namespace
// `che` ClusterRole should be created during che-operator deploy
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the comment is no longer valid. you're binding che-manage-namespace role

}
} else {
// this binding is needed to create new namespaces for workspaces
// `che` ClusterRole should be created during che-operator deploy
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the comment is no longer valid. you're binding che-create-namespaces role

@@ -164,6 +166,7 @@ func GetConfigMapData(cr *orgv1.CheCluster) (cheEnv map[string]string) {
CheDebugServer: cheDebug,
CheInfrastructureActive: infra,
CheInfraKubernetesServiceAccountName: "che-workspace",
CheWorkspaceClusterRole: cheWorkspaceClusterRole,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

formatting looks bit off here

@sparkoo
Copy link
Member

sparkoo commented Jan 28, 2020

When used with chectl, I'm getting:

E0128 07:19:57.695018       1 reflector.go:134] sigs.k8s.io/controller-runtime/pkg/cache/internal/informers_map.go:196: Failed to list *v1.ClusterRoleBinding: clusterrolebindings.rbac.authorization.k8s.io is forbidden: User "system:serviceaccount:che:che-operator" cannot list resource "clusterrolebindings" in API group "rbac.authorization.k8s.io" at the cluster scope

you can try with

chectl server:start --installer=operator --platform=crc --che-operator-image=quay.io/mvala/che-operator:namespace

@sparkoo sparkoo self-requested a review January 28, 2020 07:23
Copy link
Member

@sparkoo sparkoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

currently does not work with chectl

@sparkoo
Copy link
Member

sparkoo commented Jan 28, 2020

It looks like the patch is not actually changing default namespace. It has to be defined in CheCluster CR yaml, whitch is now empty https://github.com/eclipse/che-operator/blob/pr/137/deploy/crds/org_v1_che_cr.yaml#L57
It can be done as separate PR. This PR will make it ready for it.

@AndrienkoAleksandr
Copy link
Contributor Author

currently does not work with chectl

pr for chectl che-incubator/chectl#469 . @sparkoo Did you tested this one?

@sparkoo
Copy link
Member

sparkoo commented Jan 28, 2020

currently does not work with chectl

pr for chectl che-incubator/chectl#469 . @sparkoo Did you tested this one?

no :) will do

@sparkoo
Copy link
Member

sparkoo commented Jan 28, 2020

works with che-incubator/chectl#469. Just need to properly handle templates.

…the minikube: create own unique clusterrole and clusterrolebinding for Che server. We need it if we want to have working few che in the same cluster in the different namespaces.

Signed-off-by: Oleksandr Andriienko <oandriie@redhat.com>
@che-bot
Copy link
Contributor

che-bot commented Feb 4, 2020

Can one of the admins verify this patch?

Signed-off-by: Oleksandr Andriienko <oandriie@redhat.com>
…r roles

Signed-off-by: Oleksandr Andriienko <oandriie@redhat.com>
Signed-off-by: Oleksandr Andriienko <oandriie@redhat.com>
@AndrienkoAleksandr
Copy link
Contributor Author

Hello, @davidfestal, @tolusha , @mmorhun . I completed testing current pr with OLM on the minikube and CRC clutster. Looks like everything works just fine. Could you review pr, please?

}

// this binding is needed to manage che workspaces out of che namespace
// `${namespace}-clusterrole-manage-namespaces` ClusterRole should be created during che-operator deploy
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If ClusterRole is created during che-operator deploy, like this comment say, why it is created again here https://github.com/eclipse/che-operator/pull/156/files#diff-d9445e614f0d728fd140771b0fd29c50R1315 ?

Copy link
Contributor Author

@AndrienkoAleksandr AndrienkoAleksandr Feb 5, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OLM auto-generate unique names for che-operator ClusterRoles. ClusterRole object is not namespaced it has wider scope. That's why olm generate name to have ability to use few operators in the same cluster with own specific version of the ClusterRoles and their rules. We can not find and reuse this roles for che-server by name, That's why I created for che-server own Cluster roles.
P.S.: Theoretically we can reuse che-operator cluster role using labels, but I used current approach.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, ok. thanks

Copy link
Member

@ibuziuk ibuziuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nickboldt @l0rd is it planned to have this change in 7.9.0 ? this would affect defaults for CRW I think

@@ -131,6 +131,7 @@ Or you can build in a container:
docker run -ti -v /tmp:/tmp -v ${OPERATOR_REPO}:/opt/app-root/src/go/src/github.com/eclipse/che-operator registry.redhat.io/devtools/go-toolset-rhel7:1.11.5-3 sh -c "OOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o /tmp/run-tests /opt/app-root/src/go/src/github.com/eclipse/che-operator/e2e/*.go"
cp /tmp/run-tests ${OPERATOR_REPO}/run-tests
```
> Notice: if you don't have redhat subscription, use public image registry.access.redhat.com/devtools/go-toolset-rhel7:latest
Copy link
Contributor

@mmorhun mmorhun Feb 5, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is not right that we have links to private images in Che project.
But this is out of scope of this PR.

Copy link
Contributor

@mmorhun mmorhun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.
Tested with default che namespace and everything worked for me.

@AndrienkoAleksandr
Copy link
Contributor Author

Sorry guys, pr moved #166, because Ci become crazy with branch name pr/137 ... And github doesn't provide ability to rename target branch for pr. I can change base branch, but not target.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants