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

chore: Update rbac authorization k8s from v1beta1 to v1 #1733

Merged
merged 2 commits into from
Oct 2, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion deploy/addons/master/master-role-binding.tmpl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1beta1
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: {{ .Name }}
namespace: {{ .Namespace }}
Expand Down
2 changes: 1 addition & 1 deletion deploy/addons/master/master-role.tmpl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
kind: Role
apiVersion: rbac.authorization.k8s.io/v1beta1
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: {{ .Name }}
namespace: {{ .Namespace }}
Expand Down
2 changes: 1 addition & 1 deletion deploy/builder-role-binding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# ---------------------------------------------------------------------------

kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1beta1
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: camel-k-builder
labels:
Expand Down
2 changes: 1 addition & 1 deletion deploy/builder-role-kubernetes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# ---------------------------------------------------------------------------

kind: Role
apiVersion: rbac.authorization.k8s.io/v1beta1
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: camel-k-builder
labels:
Expand Down
2 changes: 1 addition & 1 deletion deploy/builder-role-openshift.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# ---------------------------------------------------------------------------

kind: Role
apiVersion: rbac.authorization.k8s.io/v1beta1
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: camel-k-builder
labels:
Expand Down
2 changes: 1 addition & 1 deletion deploy/operator-role-binding-events.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# ---------------------------------------------------------------------------

kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1beta1
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: camel-k-operator-events
labels:
Expand Down
2 changes: 1 addition & 1 deletion deploy/operator-role-binding-knative.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# ---------------------------------------------------------------------------

kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1beta1
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: camel-k-operator-knative
labels:
Expand Down
2 changes: 1 addition & 1 deletion deploy/operator-role-binding-servicemonitors.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# ---------------------------------------------------------------------------

kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1beta1
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: camel-k-operator-servicemonitors
labels:
Expand Down
2 changes: 1 addition & 1 deletion deploy/operator-role-binding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# ---------------------------------------------------------------------------

kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1beta1
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: camel-k-operator
labels:
Expand Down
2 changes: 1 addition & 1 deletion deploy/operator-role-events.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# ---------------------------------------------------------------------------

kind: Role
apiVersion: rbac.authorization.k8s.io/v1beta1
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: camel-k-operator-events
labels:
Expand Down
2 changes: 1 addition & 1 deletion deploy/operator-role-knative.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# ---------------------------------------------------------------------------

kind: Role
apiVersion: rbac.authorization.k8s.io/v1beta1
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: camel-k-operator-knative
labels:
Expand Down
2 changes: 1 addition & 1 deletion deploy/operator-role-kubernetes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# ---------------------------------------------------------------------------

kind: Role
apiVersion: rbac.authorization.k8s.io/v1beta1
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: camel-k-operator
labels:
Expand Down
2 changes: 1 addition & 1 deletion deploy/operator-role-olm-cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# ---------------------------------------------------------------------------

kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1beta1
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: camel-k-operator
labels:
Expand Down
2 changes: 1 addition & 1 deletion deploy/operator-role-olm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# ---------------------------------------------------------------------------

kind: Role
apiVersion: rbac.authorization.k8s.io/v1beta1
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: camel-k-operator
labels:
Expand Down
2 changes: 1 addition & 1 deletion deploy/operator-role-openshift.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# ---------------------------------------------------------------------------

kind: Role
apiVersion: rbac.authorization.k8s.io/v1beta1
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: camel-k-operator
labels:
Expand Down
2 changes: 1 addition & 1 deletion deploy/operator-role-servicemonitors.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# ---------------------------------------------------------------------------

kind: Role
apiVersion: rbac.authorization.k8s.io/v1beta1
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: camel-k-operator-servicemonitors
labels:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ metadata:
name: camel-k-pipeline
---
kind: Role
apiVersion: rbac.authorization.k8s.io/v1beta1
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: camel-k-pipeline
rules:
Expand Down Expand Up @@ -166,7 +166,7 @@ rules:
- create
---
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1beta1
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: camel-k-pipeline
subjects:
Expand Down
2 changes: 1 addition & 1 deletion helm/camel-k/templates/operator-role-binding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# ---------------------------------------------------------------------------

kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1beta1
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: camel-k-operator
labels:
Expand Down
2 changes: 1 addition & 1 deletion helm/camel-k/templates/operator-role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# ---------------------------------------------------------------------------

kind: Role
apiVersion: rbac.authorization.k8s.io/v1beta1
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: camel-k-operator
labels:
Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/uninstall.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func newCmdUninstall(rootCmdOptions *RootCmdOptions) (*cobra.Command, *uninstall
}

cmd.Flags().Bool("skip-operator", false, "Do not uninstall the Camel K Operator in the current namespace")
cmd.Flags().Bool("skip-crd", true, "Do not uninstall the Camel-k Custom Resource Definitions (CRD)")
cmd.Flags().Bool("skip-crd", true, "Do not uninstall the Camel K Custom Resource Definitions (CRD)")
cmd.Flags().Bool("skip-role-bindings", false, "Do not uninstall the Camel K Role Bindings in the current namespace")
cmd.Flags().Bool("skip-roles", false, "Do not uninstall the Camel K Roles in the current namespace")
cmd.Flags().Bool("skip-cluster-roles", true, "Do not uninstall the Camel K Cluster Roles")
Expand All @@ -60,7 +60,7 @@ func newCmdUninstall(rootCmdOptions *RootCmdOptions) (*cobra.Command, *uninstall
cmd.Flags().String("olm-package", olm.DefaultPackage, "Name of the Camel K package in the OLM source or marketplace")
cmd.Flags().String("olm-global-namespace", olm.DefaultGlobalNamespace, "A namespace containing an OperatorGroup that defines "+
"global scope for the operator (used in combination with the --global flag)")
cmd.Flags().Bool("all", false, "Do uninstall all Camel-K resources")
cmd.Flags().Bool("all", false, "Do uninstall all Camel K resources")

return &cmd, &options
}
Expand Down
12 changes: 6 additions & 6 deletions pkg/install/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (

appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
"k8s.io/api/rbac/v1beta1"
rbacv1 "k8s.io/api/rbac/v1"
k8serrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
Expand Down Expand Up @@ -81,9 +81,9 @@ func OperatorOrCollect(ctx context.Context, c client.Client, cfg OperatorConfigu
}

// Turn Role & RoleBinding into their equivalent cluster types
if r, ok := o.(*v1beta1.Role); ok {
if r, ok := o.(*rbacv1.Role); ok {
if strings.HasPrefix(r.Name, "camel-k-operator") {
o = &v1beta1.ClusterRole{
o = &rbacv1.ClusterRole{
ObjectMeta: metav1.ObjectMeta{
Namespace: cfg.Namespace,
Name: r.Name,
Expand All @@ -93,17 +93,17 @@ func OperatorOrCollect(ctx context.Context, c client.Client, cfg OperatorConfigu
}
}

if rb, ok := o.(*v1beta1.RoleBinding); ok {
if rb, ok := o.(*rbacv1.RoleBinding); ok {
if strings.HasPrefix(rb.Name, "camel-k-operator") {
rb.Subjects[0].Namespace = cfg.Namespace

o = &v1beta1.ClusterRoleBinding{
o = &rbacv1.ClusterRoleBinding{
ObjectMeta: metav1.ObjectMeta{
Namespace: cfg.Namespace,
Name: rb.Name,
},
Subjects: rb.Subjects,
RoleRef: v1beta1.RoleRef{
RoleRef: rbacv1.RoleRef{
APIGroup: rb.RoleRef.APIGroup,
Kind: "ClusterRole",
Name: rb.RoleRef.Name,
Expand Down