Skip to content

Commit

Permalink
fix(operator): missing owns on controllers
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremylvln committed Mar 5, 2022
1 parent 1b45563 commit abd625b
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 6 deletions.
16 changes: 13 additions & 3 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,23 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Prepare Docker metadata
id: docker-metadata
uses: docker/metadata-action@v3
with:
images: ghcr.io/iamblueslime/shulker-operator
tags: |
type=ref,event=branch
type=sha,format=long
type=sha
type=raw,value=latest
- name: Build and push
uses: docker/build-push-action@v2
with:
push: true
tags: ghcr.io/iamblueslime/shulker-operator:latest
cache-from: type=registry,ref=ghcr.io/iamblueslime/shulker-operator:latest
cache-to: type=inline
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

deploy-plugins:
runs-on: ubuntu-latest
Expand Down
2 changes: 2 additions & 0 deletions controllers/minecraftcluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"context"

corev1 "k8s.io/api/core/v1"
rbacv1 "k8s.io/api/rbac/v1"
k8serrors "k8s.io/apimachinery/pkg/api/errors"
meta "k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -146,5 +147,6 @@ func (r *MinecraftClusterReconciler) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
For(&shulkermciov1alpha1.MinecraftCluster{}).
Owns(&corev1.Service{}).
Owns(&rbacv1.Role{}).
Complete(r)
}
1 change: 1 addition & 0 deletions controllers/minecraftserver_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ func (r *MinecraftServerReconciler) SetupWithManager(mgr ctrl.Manager) error {
For(&shulkermciov1alpha1.MinecraftServer{}).
Owns(&corev1.Pod{}).
Owns(&corev1.ConfigMap{}).
Owns(&corev1.Secret{}).
Owns(&corev1.Service{}).
Complete(r)
}
4 changes: 4 additions & 0 deletions controllers/proxydeployment_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (

appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
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 @@ -136,6 +137,9 @@ func (r *ProxyDeploymentReconciler) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
For(&shulkermciov1alpha1.ProxyDeployment{}).
Owns(&appsv1.Deployment{}).
Owns(&corev1.ConfigMap{}).
Owns(&corev1.Service{}).
Owns(&corev1.ServiceAccount{}).
Owns(&rbacv1.RoleBinding{}).
Complete(r)
}
2 changes: 1 addition & 1 deletion internal/resource/cluster/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func (b *MinecraftClusterResourceBuilder) ResourceBuilders() ([]common.ResourceB
}

func (b *MinecraftClusterResourceBuilder) getRoleName() string {
return fmt.Sprintf("%s-cluster-watch", b.Instance.Name)
return fmt.Sprintf("%s-cluster-status-watch", b.Instance.Name)
}

func (b *MinecraftClusterResourceBuilder) getLabels() map[string]string {
Expand Down
2 changes: 1 addition & 1 deletion internal/resource/cluster/role.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (b *MinecraftClusterRoleBuilder) Update(object client.Object) error {
role.Rules = []rbacv1.PolicyRule{
{
APIGroups: []string{"shulkermc.io"},
Resources: []string{"minecraftclusters"},
Resources: []string{"minecraftclusters/status"},
Verbs: []string{"get", "watch"},
ResourceNames: []string{b.Instance.Name},
},
Expand Down
2 changes: 1 addition & 1 deletion internal/resource/proxy/rolebinding.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func (b *ProxyDeploymentRoleBindingBuilder) Build() (client.Object, error) {
RoleRef: rbacv1.RoleRef{
APIGroup: "rbac.authorization.k8s.io",
Kind: "Role",
Name: fmt.Sprintf("%s-cluster-watch", b.Cluster.Name),
Name: fmt.Sprintf("%s-cluster-status-watch", b.Cluster.Name),
},
}, nil
}
Expand Down

0 comments on commit abd625b

Please sign in to comment.