Skip to content

Commit

Permalink
Add Redis service account name to CRD (#1001)
Browse files Browse the repository at this point in the history
* upgrade controller-runtime version (#1034)

upgrade controller runtime version

Signed-off-by: coderth <coderth@outlook.com>
Signed-off-by: Dipo Ajayi <ajayidipo@ymail.com>

* Add the missing github-cr proxy cache module (#1035)

Add the missing github proxy cache module

Signed-off-by: Zoltan Langi <zoltan.langi@gmail.com>
Co-authored-by: Zoltan Langi <zoltan.langi@gmail.com>
Signed-off-by: Dipo Ajayi <ajayidipo@ymail.com>

* Add service account name to cr (#3)

* Included Service Account to Redis CR

Signed-off-by: Oladipupo Ajayi <ajayidipo@ymail.com>

* Revert deployment change

Signed-off-by: Oladipupo Ajayi <ajayidipo@ymail.com>
Signed-off-by: Dipo Ajayi <ajayidipo@ymail.com>

---------

Signed-off-by: coderth <coderth@outlook.com>
Signed-off-by: Dipo Ajayi <ajayidipo@ymail.com>
Signed-off-by: Zoltan Langi <zoltan.langi@gmail.com>
Signed-off-by: Oladipupo Ajayi <ajayidipo@ymail.com>
Co-authored-by: Noah Tang <51119718+CoderTH@users.noreply.github.com>
Co-authored-by: Zoltan <36501500+zlangi@users.noreply.github.com>
Co-authored-by: Zoltan Langi <zoltan.langi@gmail.com>
  • Loading branch information
4 people committed May 25, 2023
1 parent e2dc956 commit ba4d731
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 3 deletions.
4 changes: 4 additions & 0 deletions apis/goharbor.io/v1beta1/harborcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,10 @@ type RedisServer struct {
// +kubebuilder:validation:Optional
// Storage is the size of the redis storage.
Storage string `json:"storage,omitempty"`

// +kubebuilder:validation:Optional
// ServiceAccountName is the service account name of the redis server.
ServiceAccountName string `json:"serviceAccountName,omitempty"`
}

type Database struct {
Expand Down
4 changes: 4 additions & 0 deletions manifests/cluster/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9745,6 +9745,10 @@ spec:
https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/'
type: object
type: object
serviceAccountName:
description: ServiceAccountName is the service account
name of the redis server.
type: string
storage:
description: Storage is the size of the redis storage.
type: string
Expand Down
4 changes: 4 additions & 0 deletions manifests/harbor/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9745,6 +9745,10 @@ spec:
https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/'
type: object
type: object
serviceAccountName:
description: ServiceAccountName is the service account
name of the redis server.
type: string
storage:
description: Storage is the size of the redis storage.
type: string
Expand Down
15 changes: 12 additions & 3 deletions pkg/cluster/controllers/cache/resource_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,10 @@ func (rm *redisResourceManager) GetCacheCR(ctx context.Context, harborcluster *g
Spec: pvc.Spec,
},
},
Image: image,
ImagePullPolicy: rm.getImagePullPolicy(ctx, harborcluster),
ImagePullSecrets: rm.getImagePullSecrets(ctx, harborcluster),
Image: image,
ImagePullPolicy: rm.getImagePullPolicy(ctx, harborcluster),
ImagePullSecrets: rm.getImagePullSecrets(ctx, harborcluster),
ServiceAccountName: rm.getServiceAccountName(ctx, harborcluster),
},
Sentinel: redisOp.SentinelSettings{
Replicas: int32(rm.GetClusterServerReplica()),
Expand Down Expand Up @@ -242,3 +243,11 @@ func (rm *redisResourceManager) getImagePullSecrets(_ context.Context, harborclu

return nil
}

func (rm *redisResourceManager) getServiceAccountName(_ context.Context, harborcluster *goharborv1.HarborCluster) string {
if rm.cluster.Spec.Cache.Spec.RedisFailover != nil && rm.cluster.Spec.Cache.Spec.RedisFailover.Server != nil {
return harborcluster.Spec.Cache.Spec.RedisFailover.Server.ServiceAccountName
}

return ""
}

0 comments on commit ba4d731

Please sign in to comment.