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

Fea: add imagePullSecret for Broker/Nameservice/Console #90

Merged
merged 1 commit into from
Mar 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 5 additions & 0 deletions deploy/crds/rocketmq_v1alpha1_broker_crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ spec:
imagePullPolicy:
description: ImagePullPolicy defines how the image is pulled
type: string
imagePullSecrets:
description: The secrets used to pull image from private registry
items:
type: object
type: array
nameServers:
description: NameServers defines the name service list e.g. 192.168.1.1:9876;192.168.1.2:9876
type: string
Expand Down
5 changes: 5 additions & 0 deletions deploy/crds/rocketmq_v1alpha1_nameservice_crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ spec:
imagePullPolicy:
description: ImagePullPolicy defines how the image is pulled.
type: string
imagePullSecrets:
description: The secrets used to pull image from private registry
items:
type: object
type: array
nameServiceImage:
description: NameServiceImage is the name service image
type: string
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/rocketmq/v1alpha1/broker_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ type BrokerSpec struct {
PodSecurityContext *corev1.PodSecurityContext `json:"securityContext,omitempty"`
// Container Security Context
ContainerSecurityContext *corev1.SecurityContext `json:"containerSecurityContext,omitempty"`
// The secrets used to pull image from private registry
ImagePullSecrets []corev1.LocalObjectReference `json:"imagePullSecrets,omitempty"`
}

// BrokerStatus defines the observed state of Broker
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/rocketmq/v1alpha1/nameservice_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ type NameServiceSpec struct {
PodSecurityContext *corev1.PodSecurityContext `json:"securityContext,omitempty"`
// Container Security Context
ContainerSecurityContext *corev1.SecurityContext `json:"containerSecurityContext,omitempty"`
// The secrets used to pull image from private registry
ImagePullSecrets []corev1.LocalObjectReference `json:"imagePullSecrets,omitempty"`
}

// NameServiceStatus defines the observed state of NameService
Expand Down
1 change: 1 addition & 0 deletions pkg/controller/broker/broker_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ func (r *ReconcileBroker) getBrokerStatefulSet(broker *rocketmqv1alpha1.Broker,
Labels: ls,
},
Spec: corev1.PodSpec{
ImagePullSecrets: broker.Spec.ImagePullSecrets,
Containers: []corev1.Container{{
Resources: broker.Spec.Resources,
Image: broker.Spec.BrokerImage,
Expand Down
11 changes: 6 additions & 5 deletions pkg/controller/console/console_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,13 +199,14 @@ func newDeploymentForCR(cr *rocketmqv1alpha1.Console) *appsv1.Deployment {
Labels: cr.Spec.ConsoleDeployment.Spec.Template.ObjectMeta.Labels,
},
Spec: corev1.PodSpec{
ImagePullSecrets: cr.Spec.ConsoleDeployment.Spec.Template.Spec.ImagePullSecrets,
Containers: []corev1.Container{{
Resources: cr.Spec.ConsoleDeployment.Spec.Template.Spec.Containers[0].Resources,
Image: cr.Spec.ConsoleDeployment.Spec.Template.Spec.Containers[0].Image,
Name: cr.Spec.ConsoleDeployment.Spec.Template.Spec.Containers[0].Name,
Resources: cr.Spec.ConsoleDeployment.Spec.Template.Spec.Containers[0].Resources,
Image: cr.Spec.ConsoleDeployment.Spec.Template.Spec.Containers[0].Image,
Name: cr.Spec.ConsoleDeployment.Spec.Template.Spec.Containers[0].Name,
ImagePullPolicy: cr.Spec.ConsoleDeployment.Spec.Template.Spec.Containers[0].ImagePullPolicy,
Env: append(cr.Spec.ConsoleDeployment.Spec.Template.Spec.Containers[0].Env, env),
Ports: cr.Spec.ConsoleDeployment.Spec.Template.Spec.Containers[0].Ports,
Env: append(cr.Spec.ConsoleDeployment.Spec.Template.Spec.Containers[0].Env, env),
Ports: cr.Spec.ConsoleDeployment.Spec.Template.Spec.Containers[0].Ports,
}},
},
},
Expand Down
5 changes: 3 additions & 2 deletions pkg/controller/nameservice/nameservice_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,9 @@ func (r *ReconcileNameService) statefulSetForNameService(nameService *rocketmqv1
Labels: ls,
},
Spec: corev1.PodSpec{
HostNetwork: nameService.Spec.HostNetwork,
DNSPolicy: nameService.Spec.DNSPolicy,
HostNetwork: nameService.Spec.HostNetwork,
DNSPolicy: nameService.Spec.DNSPolicy,
ImagePullSecrets: nameService.Spec.ImagePullSecrets,
Containers: []corev1.Container{{
Resources: nameService.Spec.Resources,
Image: nameService.Spec.NameServiceImage,
Expand Down