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

chore: change svc template type #929

Merged
merged 1 commit into from
Aug 17, 2023
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
2 changes: 2 additions & 0 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ jobs:
--set image.tag=${{ github.sha }} \
--namespace emqx-operator-system \
--create-namespace
- name: Enable debug
run: |
kubectl patch -n emqx-operator-system deployment emqx-operator-controller-manager \
--type=json \
-p='[{"op": "add", "path": "/spec/template/spec/containers/0/args/-", "value": "--zap-devel=true"}]'
Expand Down
4 changes: 2 additions & 2 deletions apis/apps/v2beta1/emqx_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ type EMQXSpec struct {

// DashboardServiceTemplate is the object that describes the EMQX dashboard service that will be created
// This service always selector the EMQX core node
DashboardServiceTemplate *corev1.Service `json:"dashboardServiceTemplate,omitempty"`
DashboardServiceTemplate *ServiceTemplate `json:"dashboardServiceTemplate,omitempty"`
// ListenersServiceTemplate is the object that describes the EMQX listener service that will be created
// If the EMQX replicant node exist, this service will selector the EMQX replicant node
// Else this service will selector EMQX core node
ListenersServiceTemplate *corev1.Service `json:"listenersServiceTemplate,omitempty"`
ListenersServiceTemplate *ServiceTemplate `json:"listenersServiceTemplate,omitempty"`
}

type BootstrapAPIKey struct {
Expand Down
4 changes: 2 additions & 2 deletions apis/apps/v2beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

154 changes: 0 additions & 154 deletions config/crd/bases/apps.emqx.io_emqxes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9556,10 +9556,6 @@ spec:
type: object
dashboardServiceTemplate:
properties:
apiVersion:
type: string
kind:
type: string
metadata:
properties:
annotations:
Expand Down Expand Up @@ -9668,79 +9664,6 @@ spec:
type:
type: string
type: object
status:
properties:
conditions:
items:
properties:
lastTransitionTime:
format: date-time
type: string
message:
maxLength: 32768
type: string
observedGeneration:
format: int64
minimum: 0
type: integer
reason:
maxLength: 1024
minLength: 1
pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$
type: string
status:
enum:
- "True"
- "False"
- Unknown
type: string
type:
maxLength: 316
pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$
type: string
required:
- lastTransitionTime
- message
- reason
- status
- type
type: object
type: array
x-kubernetes-list-map-keys:
- type
x-kubernetes-list-type: map
loadBalancer:
properties:
ingress:
items:
properties:
hostname:
type: string
ip:
type: string
ports:
items:
properties:
error:
maxLength: 316
pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$
type: string
port:
format: int32
type: integer
protocol:
default: TCP
type: string
required:
- port
- protocol
type: object
type: array
x-kubernetes-list-type: atomic
type: object
type: array
type: object
type: object
type: object
image:
type: string
Expand All @@ -9756,10 +9679,6 @@ spec:
type: array
listenersServiceTemplate:
properties:
apiVersion:
type: string
kind:
type: string
metadata:
properties:
annotations:
Expand Down Expand Up @@ -9868,79 +9787,6 @@ spec:
type:
type: string
type: object
status:
properties:
conditions:
items:
properties:
lastTransitionTime:
format: date-time
type: string
message:
maxLength: 32768
type: string
observedGeneration:
format: int64
minimum: 0
type: integer
reason:
maxLength: 1024
minLength: 1
pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$
type: string
status:
enum:
- "True"
- "False"
- Unknown
type: string
type:
maxLength: 316
pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$
type: string
required:
- lastTransitionTime
- message
- reason
- status
- type
type: object
type: array
x-kubernetes-list-map-keys:
- type
x-kubernetes-list-type: map
loadBalancer:
properties:
ingress:
items:
properties:
hostname:
type: string
ip:
type: string
ports:
items:
properties:
error:
maxLength: 316
pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$
type: string
port:
format: int32
type: integer
protocol:
default: TCP
type: string
required:
- port
- protocol
type: object
type: array
x-kubernetes-list-type: atomic
type: object
type: array
type: object
type: object
type: object
replicantTemplate:
properties:
Expand Down
15 changes: 9 additions & 6 deletions controllers/apps/v2beta1/add_svc.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,12 @@ func generateDashboardService(instance *appsv2beta1.EMQX, configStr string) *cor
}
}

svc := instance.Spec.DashboardServiceTemplate.DeepCopy()
if svc == nil {
svc = &corev1.Service{}
svc := &corev1.Service{}
if instance.Spec.DashboardServiceTemplate != nil {
svc.ObjectMeta = *instance.Spec.DashboardServiceTemplate.ObjectMeta.DeepCopy()
svc.Spec = *instance.Spec.DashboardServiceTemplate.Spec.DeepCopy()
}

svc.Spec.Ports = appsv2beta1.MergeServicePorts(
svc.Spec.Ports,
[]corev1.ServicePort{
Expand Down Expand Up @@ -141,9 +143,10 @@ func generateListenerService(instance *appsv2beta1.EMQX, configStr string) *core
}...)
}

svc := instance.Spec.ListenersServiceTemplate.DeepCopy()
if svc == nil {
svc = &corev1.Service{}
svc := &corev1.Service{}
if instance.Spec.ListenersServiceTemplate != nil {
svc.ObjectMeta = *instance.Spec.ListenersServiceTemplate.ObjectMeta.DeepCopy()
svc.Spec = *instance.Spec.ListenersServiceTemplate.Spec.DeepCopy()
}

svc.Spec.Ports = appsv2beta1.MergeServicePorts(
Expand Down
2 changes: 1 addition & 1 deletion controllers/apps/v2beta1/add_svc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func TestGenerateDashboardService(t *testing.T) {
Labels: appsv2beta1.DefaultCoreLabels(emqx),
},
},
DashboardServiceTemplate: &corev1.Service{
DashboardServiceTemplate: &appsv2beta1.ServiceTemplate{
ObjectMeta: metav1.ObjectMeta{
Name: "emqx-dashboard",
Labels: map[string]string{
Expand Down
Loading