Commit dcbdece5 authored by Edmund Ochieng's avatar Edmund Ochieng

Merge branch 'autoscaling' into 'master'

Add support for auto-scaling the GitLab instance

Closes #9

See merge request !18
parents 3544ab8f 39870211
Pipeline #189662852 passed with stages
in 12 minutes and 10 seconds
......@@ -33,7 +33,8 @@ type GitLabSpec struct {
Database *DatabaseSpec `json:"postgres,omitempty"`
CertIssuer *ACMEOptions `json:"acme,omitempty"`
// Volume for Gitaly statefulset
Volume VolumeSpec `json:"volume,omitempty"`
Volume VolumeSpec `json:"volume,omitempty"`
AutoScaling *AutoScalingSpec `json:"autoscaling,omitempty"`
}
// RedisSpec defines Redis options
......@@ -108,6 +109,16 @@ type SMTPConfiguration struct {
DisplayName string `json:"displayName,omitempty"`
}
// AutoScalingSpec are the parameters to configure autoscaling
type AutoScalingSpec struct {
// MinReplicas is the lower limit to scale down to
MinReplicas *int32 `json:"minReplicas,omitempty"`
// MaxReplicas is the upper limit to scale up to
MaxReplicas int32 `json:"maxReplicas,omitempty"`
// TargetCPU is the CPU utilization threshold percentage
TargetCPU *int32 `json:"targetCPU,omitempty"`
}
// ACMEOptions defines the values for the
// ACME service that will provide certificates
type ACMEOptions struct {
......
......@@ -52,6 +52,31 @@ func (in *ACMEOptions) DeepCopy() *ACMEOptions {
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *AutoScalingSpec) DeepCopyInto(out *AutoScalingSpec) {
*out = *in
if in.MinReplicas != nil {
in, out := &in.MinReplicas, &out.MinReplicas
*out = new(int32)
**out = **in
}
if in.TargetCPU != nil {
in, out := &in.TargetCPU, &out.TargetCPU
*out = new(int32)
**out = **in
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AutoScalingSpec.
func (in *AutoScalingSpec) DeepCopy() *AutoScalingSpec {
if in == nil {
return nil
}
out := new(AutoScalingSpec)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *DatabaseSpec) DeepCopyInto(out *DatabaseSpec) {
*out = *in
......@@ -238,6 +263,11 @@ func (in *GitLabSpec) DeepCopyInto(out *GitLabSpec) {
(*in).DeepCopyInto(*out)
}
out.Volume = in.Volume
if in.AutoScaling != nil {
in, out := &in.AutoScaling, &out.AutoScaling
*out = new(AutoScalingSpec)
(*in).DeepCopyInto(*out)
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GitLabSpec.
......
......@@ -1538,6 +1538,22 @@ spec:
type: object
type: array
type: object
autoscaling:
description: AutoScalingSpec are the parameters to configure autoscaling
properties:
maxReplicas:
description: MaxReplicas is the upper limit to scale up to
format: int32
type: integer
minReplicas:
description: MinReplicas is the lower limit to scale down to
format: int32
type: integer
targetCPU:
description: TargetCPU is the CPU utilization threshold percentage
format: int32
type: integer
type: object
objectStore:
description: ObjectStoreSpec defines options for Gitlab registry
properties:
......
......@@ -90,6 +90,18 @@ rules:
- get
- patch
- update
- apiGroups:
- autoscaling
resources:
- horizontalpodautoscalers
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- batch
resources:
......
......@@ -16,3 +16,7 @@ spec:
postgres:
volume:
capacity: 8Gi
autoscaling:
minReplicas: 2
maxReplicas: 5
targetCPU: 60
package gitlab
import (
gitlabv1beta1 "gitlab.com/gitlab-org/gl-openshift/gitlab-operator/api/v1beta1"
appsv1 "k8s.io/api/apps/v1"
autoscalingv1 "k8s.io/api/autoscaling/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// takes deployment labels and updates them for HPA
func getHPALabels(labels map[string]string) map[string]string {
labels["app.kubernetes.io/component"] = "hpa"
return labels
}
// HorizontalAutoscaler return HPA for deployment passed
func HorizontalAutoscaler(deployment *appsv1.Deployment, cr *gitlabv1beta1.GitLab) *autoscalingv1.HorizontalPodAutoscaler {
labels := getHPALabels(deployment.ObjectMeta.Labels)
if cr.Spec.AutoScaling == nil {
return nil
}
return &autoscalingv1.HorizontalPodAutoscaler{
ObjectMeta: metav1.ObjectMeta{
Name: deployment.Name,
Namespace: cr.Namespace,
Labels: labels,
},
Spec: autoscalingv1.HorizontalPodAutoscalerSpec{
ScaleTargetRef: autoscalingv1.CrossVersionObjectReference{
Kind: deployment.Kind,
APIVersion: deployment.APIVersion,
Name: deployment.Name,
},
MinReplicas: cr.Spec.AutoScaling.MinReplicas,
MaxReplicas: cr.Spec.AutoScaling.MaxReplicas,
TargetCPUUtilizationPercentage: cr.Spec.AutoScaling.TargetCPU,
},
}
}
......@@ -18,6 +18,8 @@ package controllers
import (
"context"
"reflect"
"strings"
"time"
"github.com/go-logr/logr"
......@@ -39,6 +41,7 @@ import (
gitlabv1beta1 "gitlab.com/gitlab-org/gl-openshift/gitlab-operator/api/v1beta1"
gitlabctl "gitlab.com/gitlab-org/gl-openshift/gitlab-operator/controllers/gitlab"
gitlabutils "gitlab.com/gitlab-org/gl-openshift/gitlab-operator/controllers/utils"
autoscalingv1 "k8s.io/api/autoscaling/v1"
"k8s.io/apimachinery/pkg/api/errors"
)
......@@ -62,6 +65,7 @@ type GitLabReconciler struct {
// +kubebuilder:rbac:groups=extensions,resources=ingresses,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=monitoring.coreos.com,resources=servicemonitors,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=monitoring.coreos.com,resources=prometheuses,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=autoscaling,resources=horizontalpodautoscalers,verbs=get;list;watch;create;update;patch;delete
// Reconcile triggers when an event occurs on the watched resource
func (r *GitLabReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) {
......@@ -118,6 +122,10 @@ func (r *GitLabReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) {
return ctrl.Result{}, err
}
if err := r.setupAutoscaling(ctx, gitlab); err != nil {
return ctrl.Result{}, err
}
// Deploy route is on Openshift, Ingress otherwise
if err := r.exposeGitLabInstance(gitlab); err != nil {
return ctrl.Result{}, err
......@@ -275,23 +283,23 @@ func (r *GitLabReconciler) reconcileServiceMonitor(cr *gitlabv1beta1.GitLab) err
func (r *GitLabReconciler) reconcileDeployments(ctx context.Context, cr *gitlabv1beta1.GitLab) error {
if err := r.reconcileWebserviceDeployment(cr); err != nil {
if err := r.reconcileWebserviceDeployment(ctx, cr); err != nil {
return err
}
if err := r.reconcileShellDeployment(cr); err != nil {
if err := r.reconcileShellDeployment(ctx, cr); err != nil {
return err
}
if err := r.reconcileSidekiqDeployment(cr); err != nil {
if err := r.reconcileSidekiqDeployment(ctx, cr); err != nil {
return err
}
if err := r.reconcileRegistryDeployment(cr); err != nil {
if err := r.reconcileRegistryDeployment(ctx, cr); err != nil {
return err
}
if err := r.reconcileTaskRunnerDeployment(cr); err != nil {
if err := r.reconcileTaskRunnerDeployment(ctx, cr); err != nil {
return err
}
......@@ -363,20 +371,6 @@ func (r *GitLabReconciler) maskEmailPasword(cr *gitlabv1beta1.GitLab) error {
return nil
}
func (r *GitLabReconciler) reconcileWebserviceDeployment(cr *gitlabv1beta1.GitLab) error {
webservice := gitlabctl.WebserviceDeployment(cr)
if r.isObjectFound(webservice) {
return nil
}
if err := controllerutil.SetControllerReference(cr, webservice, r.Scheme); err != nil {
return err
}
return r.Create(context.TODO(), webservice)
}
func (r *GitLabReconciler) reconcileMinioInstance(cr *gitlabv1beta1.GitLab) error {
cm := gitlabctl.MinioScriptConfigMap(cr)
if err := r.createKubernetesResource(cm, cr); err != nil {
......@@ -403,20 +397,6 @@ func (r *GitLabReconciler) reconcileMinioInstance(cr *gitlabv1beta1.GitLab) erro
return nil
}
func (r *GitLabReconciler) reconcileRegistryDeployment(cr *gitlabv1beta1.GitLab) error {
registry := gitlabctl.RegistryDeployment(cr)
if r.isObjectFound(registry) {
return nil
}
if err := controllerutil.SetControllerReference(cr, registry, r.Scheme); err != nil {
return err
}
return r.Create(context.TODO(), registry)
}
func (r *GitLabReconciler) reconcileSecrets(cr *gitlabv1beta1.GitLab) error {
var secrets []*corev1.Secret
......@@ -510,7 +490,35 @@ func (r *GitLabReconciler) reconcileServices(cr *gitlabv1beta1.GitLab) error {
return nil
}
func (r *GitLabReconciler) reconcileShellDeployment(cr *gitlabv1beta1.GitLab) error {
func (r *GitLabReconciler) reconcileWebserviceDeployment(ctx context.Context, cr *gitlabv1beta1.GitLab) error {
webservice := gitlabctl.WebserviceDeployment(cr)
if r.isObjectFound(webservice) {
return nil
}
if err := controllerutil.SetControllerReference(cr, webservice, r.Scheme); err != nil {
return err
}
return r.Create(ctx, webservice)
}
func (r *GitLabReconciler) reconcileRegistryDeployment(ctx context.Context, cr *gitlabv1beta1.GitLab) error {
registry := gitlabctl.RegistryDeployment(cr)
if r.isObjectFound(registry) {
return nil
}
if err := controllerutil.SetControllerReference(cr, registry, r.Scheme); err != nil {
return err
}
return r.Create(ctx, registry)
}
func (r *GitLabReconciler) reconcileShellDeployment(ctx context.Context, cr *gitlabv1beta1.GitLab) error {
shell := gitlabctl.ShellDeployment(cr)
if r.isObjectFound(shell) {
......@@ -521,10 +529,10 @@ func (r *GitLabReconciler) reconcileShellDeployment(cr *gitlabv1beta1.GitLab) er
return err
}
return r.Create(context.TODO(), shell)
return r.Create(ctx, shell)
}
func (r *GitLabReconciler) reconcileSidekiqDeployment(cr *gitlabv1beta1.GitLab) error {
func (r *GitLabReconciler) reconcileSidekiqDeployment(ctx context.Context, cr *gitlabv1beta1.GitLab) error {
sidekiq := gitlabctl.SidekiqDeployment(cr)
if r.isObjectFound(sidekiq) {
......@@ -535,10 +543,10 @@ func (r *GitLabReconciler) reconcileSidekiqDeployment(cr *gitlabv1beta1.GitLab)
return err
}
return r.Create(context.TODO(), sidekiq)
return r.Create(ctx, sidekiq)
}
func (r *GitLabReconciler) reconcileTaskRunnerDeployment(cr *gitlabv1beta1.GitLab) error {
func (r *GitLabReconciler) reconcileTaskRunnerDeployment(ctx context.Context, cr *gitlabv1beta1.GitLab) error {
tasker := gitlabctl.TaskRunnerDeployment(cr)
if r.isObjectFound(tasker) {
......@@ -549,7 +557,7 @@ func (r *GitLabReconciler) reconcileTaskRunnerDeployment(cr *gitlabv1beta1.GitLa
return err
}
return r.Create(context.TODO(), tasker)
return r.Create(ctx, tasker)
}
func (r *GitLabReconciler) exposeGitLabInstance(cr *gitlabv1beta1.GitLab) error {
......@@ -611,3 +619,68 @@ func (r *GitLabReconciler) reconcileCertManagerCertificates(cr *gitlabv1beta1.Gi
return r.createKubernetesResource(issuer, cr)
}
func (r *GitLabReconciler) setupAutoscaling(ctx context.Context, cr *gitlabv1beta1.GitLab) error {
selector := client.MatchingLabelsSelector{
Selector: getLabelSet(cr).AsSelector(),
}
deployments := &appsv1.DeploymentList{}
err := r.List(ctx, deployments, client.InNamespace(cr.Namespace), selector)
if err != nil {
return err
}
for _, deploy := range deployments.Items {
if err := r.reconcileHPA(ctx, &deploy, cr); err != nil {
return err
}
}
return nil
}
func (r *GitLabReconciler) reconcileHPA(ctx context.Context, deployment *appsv1.Deployment, cr *gitlabv1beta1.GitLab) error {
if strings.Contains(deployment.Name, "gitlab-exporter") {
return nil
}
hpa := gitlabctl.HorizontalAutoscaler(deployment, cr)
found := &autoscalingv1.HorizontalPodAutoscaler{}
err := r.Get(ctx, types.NamespacedName{Name: deployment.Name, Namespace: cr.Namespace}, found)
if err != nil {
if errors.IsNotFound(err) {
if err := controllerutil.SetControllerReference(cr, hpa, r.Scheme); err != nil {
return err
}
return r.Create(ctx, hpa)
}
return err
}
if cr.Spec.AutoScaling == nil {
return r.Delete(ctx, found)
}
if !reflect.DeepEqual(hpa.Spec, found.Spec) {
if *found.Spec.MinReplicas != *hpa.Spec.MinReplicas {
found.Spec.MinReplicas = hpa.Spec.MinReplicas
}
if found.Spec.MaxReplicas != hpa.Spec.MaxReplicas {
found.Spec.MaxReplicas = hpa.Spec.MaxReplicas
}
if found.Spec.TargetCPUUtilizationPercentage != hpa.Spec.TargetCPUUtilizationPercentage {
found.Spec.TargetCPUUtilizationPercentage = hpa.Spec.TargetCPUUtilizationPercentage
}
return r.Update(ctx, found)
}
return nil
}
......@@ -23,7 +23,8 @@ var EndpointMembers []string
func (r *GitLabReconciler) reconcileGitlabStatus(cr *gitlabv1beta1.GitLab) error {
// get current Gitlab resource
gitlab, err := r.retrieveUpdatedGitlabResource(cr)
gitlab := &gitlabv1beta1.GitLab{}
err := r.Get(context.TODO(), types.NamespacedName{Namespace: cr.Namespace, Name: cr.Name}, gitlab)
if err != nil {
return err
}
......@@ -140,12 +141,6 @@ func (r *GitLabReconciler) isWebserviceDeployed(cr *gitlabv1beta1.GitLab) bool {
return !reflect.DeepEqual(*webservice, appsv1.Deployment{}) || !errors.IsNotFound(err)
}
func (r *GitLabReconciler) retrieveUpdatedGitlabResource(cr *gitlabv1beta1.GitLab) (*gitlabv1beta1.GitLab, error) {
gitlab := &gitlabv1beta1.GitLab{}
err := r.Get(context.TODO(), types.NamespacedName{Namespace: cr.Namespace, Name: cr.Name}, gitlab)
return gitlab, err
}
// setGitlabStatus sets status of custom resource
func (r *GitLabReconciler) setGitlabStatus(object runtime.Object) error {
return r.Status().Update(context.TODO(), object)
......
......@@ -8,6 +8,7 @@ import (
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
)
......@@ -50,3 +51,14 @@ func (r *GitLabReconciler) ifCoreServicesReady(ctx context.Context, cr *gitlabv1
r.isEndpointReady(ctx, cr.Name+"-gitaly", cr) &&
r.isEndpointReady(ctx, cr.Name+"-redis", cr)
}
func getLabelSet(cr *gitlabv1beta1.GitLab) labels.Set {
webLabels := gitlabutils.Label(cr.Name, "webservice", gitlabutils.GitlabType)
unwantedKeys := []string{"app.kubernetes.io/component", "app.kubernetes.io/instance"}
for _, key := range unwantedKeys {
delete(webLabels, key)
}
return labels.Set(webLabels)
}
......@@ -1729,6 +1729,7 @@ k8s.io/apimachinery v0.18.5/go.mod h1:OaXp26zu/5J7p0f92ASynJa1pZo06YlV9fG7BoWbCk
k8s.io/apimachinery v0.18.6 h1:RtFHnfGNfd1N0LeSrKCUznz5xtUP1elRGvHJbL3Ntag=
k8s.io/apimachinery v0.18.6/go.mod h1:OaXp26zu/5J7p0f92ASynJa1pZo06YlV9fG7BoWbCko=
k8s.io/apimachinery v0.18.8 h1:jimPrycCqgx2QPearX3to1JePz7wSbVLq+7PdBTTwQ0=
k8s.io/apimachinery v0.19.1 h1:cwsxZazM/LA9aUsBaL4bRS5ygoM6bYp8dFk22DSYQa4=
k8s.io/apiserver v0.0.0-20190918160949-bfa5e2e684ad/go.mod h1:XPCXEwhjaFN29a8NldXA901ElnKeKLrLtREO9ZhFyhg=
k8s.io/apiserver v0.0.0-20191122221311-9d521947b1e1/go.mod h1:RbsZY5zzBIWnz4KbctZsTVjwIuOpTp4Z8oCgFHN4kZQ=
k8s.io/apiserver v0.16.7/go.mod h1:/5zSatF30/L9zYfMTl55jzzOnx7r/gGv5a5wtRp8yAw=
......@@ -1746,30 +1747,11 @@ k8s.io/cli-runtime v0.17.2/go.mod h1:aa8t9ziyQdbkuizkNLAw3qe3srSyWh9zlSB7zTqRNPI
k8s.io/cli-runtime v0.17.3/go.mod h1:X7idckYphH4SZflgNpOOViSxetiMj6xI0viMAjM81TA=
k8s.io/cli-runtime v0.17.4/go.mod h1:IVW4zrKKx/8gBgNNkhiUIc7nZbVVNhc1+HcQh+PiNHc=
k8s.io/cli-runtime v0.18.4/go.mod h1:9/hS/Cuf7NVzWR5F/5tyS6xsnclxoPLVtwhnkJG1Y4g=
k8s.io/cli-runtime v0.18.5 h1:Wr2hTNFlrb9smNqTGCfJHd21F9j0rh3jzB8Pkn0h2RE=
k8s.io/cli-runtime v0.18.5/go.mod h1:uS210tk6ngtwwIJctPLs4ul1r7XlrEtwh9dA1oB700A=
k8s.io/cli-runtime v0.18.6 h1:I8BkH5NyqMQ4zqUBmpXJ1LxIqpCH88H/1edPkPVWzjQ=
k8s.io/cli-runtime v0.18.6/go.mod h1:+G/WTNqHgUv636e5y7rhOQ7epUbRXnwmPnhOhD6t9uM=
k8s.io/client-go v0.0.0-20190620085101-78d2af792bab/go.mod h1:E95RaSlHr79aHaX0aGSwcPNfygDiPKOVXdmivCIZT0k=
k8s.io/client-go v0.0.0-20190918160344-1fbdaa4c8d90/go.mod h1:J69/JveO6XESwVgG53q3Uz5OSfgsv4uxpScmmyYOOlk=
k8s.io/client-go v0.0.0-20191122220542-ed16ecbdf3a0/go.mod h1:tyxNgOmR/Xi39HrlQ/9LQgiHJgBvmY7gp95o5GpBA4o=
k8s.io/client-go v0.16.7/go.mod h1:9kEMEeuy2LdsHHXoU2Skqh+SDso+Yhkxd/0tltvswDE=
k8s.io/client-go v0.17.0/go.mod h1:TYgR6EUHs6k45hb6KWjVD6jFZvJV4gHDikv/It0xz+k=
k8s.io/client-go v0.17.2/go.mod h1:QAzRgsa0C2xl4/eVpeVAZMvikCn8Nm81yqVx3Kk9XYI=
k8s.io/client-go v0.17.3/go.mod h1:cLXlTMtWHkuK4tD360KpWz2gG2KtdWEr/OT02i3emRQ=
k8s.io/client-go v0.17.4/go.mod h1:ouF6o5pz3is8qU0/qYL2RnoxOPqgfuidYLowytyLJmc=
k8s.io/client-go v0.17.5/go.mod h1:S8uZpBpjJJdEH/fEyxcqg7Rn0P5jH+ilkgBHjriSmNo=
k8s.io/client-go v0.18.0/go.mod h1:uQSYDYs4WhVZ9i6AIoEZuwUggLVEF64HOD37boKAtF8=
k8s.io/client-go v0.18.2/go.mod h1:Xcm5wVGXX9HAA2JJ2sSBUn3tCJ+4SVlCbl2MNNv+CIU=
k8s.io/client-go v0.18.3/go.mod h1:4a/dpQEvzAhT1BbuWW09qvIaGw6Gbu1gZYiQZIi1DMw=
k8s.io/client-go v0.18.4/go.mod h1:f5sXwL4yAZRkAtzOxRWUhA/N8XzGCb+nPZI8PfobZ9g=
k8s.io/client-go v0.18.5/go.mod h1:EsiD+7Fx+bRckKWZXnAXRKKetm1WuzPagH4iOSC8x58=
k8s.io/client-go v0.18.6 h1:I+oWqJbibLSGsZj8Xs8F0aWVXJVIoUHWaaJV3kUN/Zw=
k8s.io/client-go v0.18.6/go.mod h1:/fwtGLjYMS1MaM5oi+eXhKwG+1UHidUEXRh6cNsdO0Q=
k8s.io/client-go v1.5.1 h1:XaX/lo2/u3/pmFau8HN+sB5C/b4dc4Dmm2eXjBH4p1E=
k8s.io/client-go v11.0.0+incompatible h1:LBbX2+lOwY9flffWlJM7f1Ct8V2SRNiMRDFeiwnJo9o=
k8s.io/client-go v12.0.0+incompatible h1:YlJxncpeVUC98/WMZKC3JZGk/OXQWCZjAB4Xr3B17RY=
k8s.io/client-go v12.0.0+incompatible/go.mod h1:E95RaSlHr79aHaX0aGSwcPNfygDiPKOVXdmivCIZT0k=
k8s.io/code-generator v0.0.0-20190912054826-cd179ad6a269/go.mod h1:V5BD6M4CyaN5m+VthcclXWsVcT1Hu+glwa1bi3MIsyE=
k8s.io/code-generator v0.16.7/go.mod h1:wFdrXdVi/UC+xIfLi+4l9elsTT/uEF61IfcN2wOLULQ=
k8s.io/code-generator v0.17.0/go.mod h1:DVmfPQgxQENqDIzVR2ddLXMH34qeszkKSdH/N+s+38s=
......@@ -1826,7 +1808,6 @@ k8s.io/kubectl v0.17.2/go.mod h1:y4rfLV0n6aPmvbRCqZQjvOp3ezxsFgpqL+zF5jH/lxk=
k8s.io/kubectl v0.17.3/go.mod h1:NUn4IBY7f7yCMwSop2HCXlw/MVYP4HJBiUmOR3n9w28=
k8s.io/kubectl v0.17.4/go.mod h1:im5QWmh6fvtmJkkNm4HToLe8z9aM3jihYK5X/wOybcY=
k8s.io/kubectl v0.18.4/go.mod h1:EzB+nfeUWk6fm6giXQ8P4Fayw3dsN+M7Wjy23mTRtB0=
k8s.io/kubectl v0.18.5 h1:htctXnWqcF1VBkuzbWINqnwx/rM7byH9o2ZuHntlbJo=
k8s.io/kubectl v0.18.5/go.mod h1:LAGxvYunNuwcZst0OAMXnInFIv81/IeoAz2N1Yh+AhU=
k8s.io/kubectl v0.18.6 h1:IFPNuLPkZ59vSGQzynXY8XGz9yuOSRpkJupnobdYvO4=
k8s.io/kubectl v0.18.6/go.mod h1:3TLzFOrF9h4mlRPAvdNkDbs5NWspN4e0EnPnEB41CGo=
......@@ -1837,7 +1818,6 @@ k8s.io/metrics v0.17.4/go.mod h1:6rylW2iD3M9VppnEAAtJASY1XS8Pt9tcYh+tHxBeV3I=
k8s.io/metrics v0.18.4/go.mod h1:luze4fyI9JG4eLDZy0kFdYEebqNfi0QrG4xNEbPkHOs=
k8s.io/metrics v0.18.5/go.mod h1:pqn6YiCCxUt067ivZVo4KtvppvdykV6HHG5+7ygVkNg=
k8s.io/metrics v0.18.6/go.mod h1:iAwGeabusQNO3duHDM7BBExTUB8L+iq8PM7N9EtQw6g=
k8s.io/utils v0.0.0-20190221042446-c2654d5206da/go.mod h1:8k8uAuAQ0rXslZKaEWd0c3oVhZz7sSzSiPnVZayjIX0=
k8s.io/utils v0.0.0-20190308190857-21c4ce38f2a7/go.mod h1:8k8uAuAQ0rXslZKaEWd0c3oVhZz7sSzSiPnVZayjIX0=
k8s.io/utils v0.0.0-20190801114015-581e00157fb1/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew=
k8s.io/utils v0.0.0-20191114184206-e782cd3c129f/go.mod h1:sZAwmy6armz5eXlNoLmJcl4F1QuKu7sr+mFQ0byX7Ew=
......@@ -1868,7 +1848,6 @@ sigs.k8s.io/kustomize v2.0.3+incompatible h1:JUufWFNlI44MdtnjUqVnvh29rR37PQFzPbL
sigs.k8s.io/kustomize v2.0.3+incompatible/go.mod h1:MkjgH3RdOWrievjo6c9T245dYlB5QeXV4WCbnt/PEpU=
sigs.k8s.io/structured-merge-diff v0.0.0-20190525122527-15d366b2352e/go.mod h1:wWxsB5ozmmv/SG7nM11ayaAW51xMvak/t1r0CSlcokI=
sigs.k8s.io/structured-merge-diff v0.0.0-20190817042607-6149e4549fca/go.mod h1:IIgPezJWb76P0hotTxzDbWsMYB8APh18qZnxkomBpxA=
sigs.k8s.io/structured-merge-diff v1.0.1-0.20191108220359-b1b620dd3f06 h1:zD2IemQ4LmOcAumeiyDWXKUI2SO0NYDe3H6QGvPOVgU=
sigs.k8s.io/structured-merge-diff v1.0.1-0.20191108220359-b1b620dd3f06/go.mod h1:/ULNhyfzRopfcjskuui0cTITekDduZ7ycKN3oUT9R18=
sigs.k8s.io/structured-merge-diff v1.0.2 h1:WiMoyniAVAYm03w+ImfF9IE2G23GLR/SwDnQyaNZvPk=
sigs.k8s.io/structured-merge-diff v1.0.2/go.mod h1:IIgPezJWb76P0hotTxzDbWsMYB8APh18qZnxkomBpxA=
......
......@@ -72,11 +72,13 @@ func main() {
ctrl.SetLogger(zap.New(zap.UseDevMode(true)))
operatorScope := "namespace"
watchedNamespace, err := getWatchedNamespace()
if err != nil {
setupLog.Info("changing operator scope", "scope", "namespaced")
operatorScope = "cluster"
}
setupLog.Info("setting operator scope", "scope", operatorScope)
mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
Scheme: scheme,
MetricsBindAddress: metricsAddr,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment