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

【ISSUE #73】support mounting a configMap to rocketmq-dashboard #132

Closed
wants to merge 5 commits into from
Closed
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
50 changes: 47 additions & 3 deletions example/rocketmq_v1alpha1_console_cr.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,47 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: console-config
data:
application.yml: |
server:
port: 8080
servlet:
encoding:
charset: UTF-8
enabled: true
force: true
spring:
application:
name: rocketmq-dashboard
logging:
config: classpath:logback.xml
rocketmq:
config:
namesrvAddrs:
- XXX:XXX
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO nameserver address should be injected by rocketmq-operator, not manually configured.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shendongsd Should we also define role-permission.yml in config map?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The role-permission.yml can be added to configmap

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shendongsd Pls also add role-permission.yml to config map and reference it in Console CR.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok,I could add it later

isVIPChannel:
timeoutMillis:
dataPath: /tmp/rocketmq-console/data
enableDashBoardCollect: true
msgTrackTopicName:
ticketKey: ticket
loginRequired: false
useTLS: false
threadpool:
config:
coreSize: 10
maxSize: 10
keepAliveTime: 3000
queueSize: 5000

---
apiVersion: rocketmq.apache.org/v1alpha1
kind: Console
metadata:
name: console
namespace: default
spec:
# nameServers is the [ip:port] list of name service
nameServers: ""
# consoleDeployment define the console deployment
consoleDeployment:
apiVersion: apps/v1
Expand All @@ -26,5 +62,13 @@ spec:
containers:
- name: console
image: apacherocketmq/rocketmq-console:2.0.0
args: ["--spring.config.location=/apps/data/console/config/"]
ports:
- containerPort: 8080
- containerPort: 8080
volumeMounts:
- mountPath: "/apps/data/console/config"
name: console-config
volumes:
- name: console-config
configMap:
name: console-config
27 changes: 3 additions & 24 deletions pkg/controller/console/console_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ package console

import (
"context"
"fmt"
rocketmqv1alpha1 "github.com/apache/rocketmq-operator/pkg/apis/rocketmq/v1alpha1"
cons "github.com/apache/rocketmq-operator/pkg/constants"
"github.com/apache/rocketmq-operator/pkg/share"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
Expand All @@ -38,7 +35,6 @@ import (
"sigs.k8s.io/controller-runtime/pkg/manager"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
"sigs.k8s.io/controller-runtime/pkg/source"
"time"
)

var log = logf.Log.WithName("controller_console")
Expand Down Expand Up @@ -124,20 +120,6 @@ func (r *ReconcileConsole) Reconcile(ctx context.Context, request reconcile.Requ
return reconcile.Result{}, err
}

if instance.Spec.NameServers == "" {
// wait for name server ready if nameServers is omitted
for {
if share.IsNameServersStrInitialized {
break
} else {
log.Info("Waiting for name server ready...")
time.Sleep(time.Duration(cons.WaitForNameServerReadyInSecond) * time.Second)
}
}
} else {
share.NameServersStr = instance.Spec.NameServers
}

consoleDeployment := newDeploymentForCR(instance)

// Set Console instance as the owner and controller
Expand Down Expand Up @@ -181,11 +163,6 @@ func (r *ReconcileConsole) Reconcile(ctx context.Context, request reconcile.Requ

// newDeploymentForCR returns a deployment pod with modifying the ENV
func newDeploymentForCR(cr *rocketmqv1alpha1.Console) *appsv1.Deployment {
env := corev1.EnvVar{
Name: "JAVA_OPTS",
Value: fmt.Sprintf("-Drocketmq.namesrv.addr=%s -Dcom.rocketmq.sendMessageWithVIPChannel=false", share.NameServersStr),
}

dep := &appsv1.Deployment{
ObjectMeta: metav1.ObjectMeta{
Name: cr.Name,
Expand All @@ -207,11 +184,13 @@ func newDeploymentForCR(cr *rocketmqv1alpha1.Console) *appsv1.Deployment {
Containers: []corev1.Container{{
Resources: cr.Spec.ConsoleDeployment.Spec.Template.Spec.Containers[0].Resources,
Image: cr.Spec.ConsoleDeployment.Spec.Template.Spec.Containers[0].Image,
Args: cr.Spec.ConsoleDeployment.Spec.Template.Spec.Containers[0].Args,
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,
VolumeMounts: cr.Spec.ConsoleDeployment.Spec.Template.Spec.Containers[0].VolumeMounts,
}},
Volumes: cr.Spec.ConsoleDeployment.Spec.Template.Spec.Volumes,
},
},
},
Expand Down