Skip to content

Commit

Permalink
feat: adjust cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
kqzh committed Sep 18, 2023
1 parent df886ae commit d9b8fef
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 64 deletions.
9 changes: 9 additions & 0 deletions apis/apps/v1alpha1/nebulacluster_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,15 @@ func generateContainers(c NebulaClusterComponent, cm *corev1.ConfigMap) []corev1
flags += " --assigned_zone=$NODE_ZONE"
}

c.GenerateContainerPorts()

if !c.IsDefaultThriftPort() {
flags += " --port=" + strconv.Itoa(int(c.GetHTTPPort()))
}
if !c.IsDefaultHTTPPort() {
flags += " --ws_http_port=" + strconv.Itoa(int(c.GetHTTPPort()))
}

cmd := []string{"/bin/sh", "-ecx"}
if c.ComponentType() == GraphdComponentType && nc.IsIntraZoneReadingEnabled() {
cmd = append(cmd, fmt.Sprintf("source /node/zone; echo $NODE_ZONE; exec /usr/local/nebula/bin/nebula-%s", componentType)+
Expand Down
5 changes: 5 additions & 0 deletions apis/apps/v1alpha1/nebulacluster_component.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,11 @@ type NebulaClusterComponent interface {
IsReady() bool
GetUpdateRevision() string
UpdateComponentStatus(status *ComponentStatus)

IsDefaultThriftPort() bool
GetThriftPort() int32
IsDefaultHTTPPort() bool
GetHTTPPort() int32
}

// +k8s:deepcopy-gen=false
Expand Down
33 changes: 24 additions & 9 deletions apis/apps/v1alpha1/nebulacluster_graphd.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,14 @@ import (
)

const (
GraphdComponentType = ComponentType("graphd")
GraphdPortNameThrift = "thrift"
GraphdPortNameHTTP = "http"
GraphdPortNameHTTP2 = "http2"
defaultGraphdImage = "vesoft/nebula-graphd"
GraphdComponentType = ComponentType("graphd")
GraphdPortNameThrift = "thrift"
defaultGraphdPortThrift = 9669
GraphdPortNameHTTP = "http"
defaultGraphdPortHTTP = 19669
GraphdPortNameHTTP2 = "http2"
defaultGraphdPortHTTP2 = 19670
defaultGraphdImage = "vesoft/nebula-graphd"
)

var _ NebulaClusterComponent = &graphdComponent{}
Expand Down Expand Up @@ -144,10 +147,6 @@ func (c *graphdComponent) GenerateContainerPorts() []corev1.ContainerPort {
Name: GraphdPortNameHTTP,
ContainerPort: c.nc.Spec.Graphd.HTTPPort,
},
{
Name: GraphdPortNameHTTP2,
ContainerPort: c.nc.Spec.Graphd.HTTP2Port,
},
}
}

Expand Down Expand Up @@ -305,3 +304,19 @@ func (c *graphdComponent) GenerateConfigMap() *corev1.ConfigMap {
func (c *graphdComponent) UpdateComponentStatus(status *ComponentStatus) {
c.nc.Status.Graphd = *status
}

func (c *graphdComponent) IsDefaultThriftPort() bool {
return c.nc.Spec.Graphd.Port == defaultGraphdPortThrift
}

func (c *graphdComponent) GetThriftPort() int32 {
return c.nc.Spec.Graphd.Port
}

func (c *graphdComponent) IsDefaultHTTPPort() bool {
return c.nc.Spec.Graphd.HTTPPort == defaultGraphdPortHTTP
}

func (c *graphdComponent) GetHTTPPort() int32 {
return c.nc.Spec.Graphd.HTTPPort
}
33 changes: 24 additions & 9 deletions apis/apps/v1alpha1/nebulacluster_metad.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,14 @@ import (
)

const (
MetadComponentType = ComponentType("metad")
MetadPortNameThrift = "thrift"
MetadPortNameHTTP = "http"
MetadPortNameHTTP2 = "http2"
defaultMetadImage = "vesoft/nebula-metad"
MetadComponentType = ComponentType("metad")
MetadPortNameThrift = "thrift"
defaultMetadPortThrift = 9559
MetadPortNameHTTP = "http"
defaultMetadPortHTTP = 19559
MetadPortNameHTTP2 = "http2"
defaultMetadPortHTTP2 = 19560
defaultMetadImage = "vesoft/nebula-metad"
)

var _ NebulaClusterComponent = &metadComponent{}
Expand Down Expand Up @@ -161,10 +164,6 @@ func (c *metadComponent) GenerateContainerPorts() []corev1.ContainerPort {
Name: MetadPortNameHTTP,
ContainerPort: c.nc.Spec.Metad.HTTPPort,
},
{
Name: MetadPortNameHTTP2,
ContainerPort: c.nc.Spec.Metad.HTTP2Port,
},
}
}

Expand Down Expand Up @@ -383,3 +382,19 @@ func (c *metadComponent) GenerateConfigMap() *corev1.ConfigMap {
func (c *metadComponent) UpdateComponentStatus(status *ComponentStatus) {
c.nc.Status.Metad = *status
}

func (c *metadComponent) IsDefaultThriftPort() bool {
return c.nc.Spec.Metad.Port == defaultMetadPortThrift
}

func (c *metadComponent) GetThriftPort() int32 {
return c.nc.Spec.Metad.Port
}

func (c *metadComponent) IsDefaultHTTPPort() bool {
return c.nc.Spec.Metad.HTTPPort == defaultMetadPortHTTP
}

func (c *metadComponent) GetHTTPPort() int32 {
return c.nc.Spec.Metad.HTTPPort
}
40 changes: 26 additions & 14 deletions apis/apps/v1alpha1/nebulacluster_storaged.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,16 @@ import (
)

const (
StoragedComponentType = ComponentType("storaged")
StoragedPortNameThrift = "thrift"
StoragedPortNameHTTP = "http"
StoragedPortNameHTTP2 = "http2"
StoragedPortNameAdmin = "admin"
defaultStoragedImage = "vesoft/nebula-storaged"
StoragedComponentType = ComponentType("storaged")
StoragedPortNameThrift = "thrift"
defaultStoragedPortThrift = 9779
StoragedPortNameHTTP = "http"
defaultStoragedPortHTTP = 19779
StoragedPortNameHTTP2 = "http2"
defaultStoragedPortHTTP2 = 19780
StoragedPortNameAdmin = "admin"
defaultStoragedPortAdmin = 9778
defaultStoragedImage = "vesoft/nebula-storaged"
)

var _ NebulaClusterComponent = &storagedComponent{}
Expand Down Expand Up @@ -161,14 +165,6 @@ func (c *storagedComponent) GenerateContainerPorts() []corev1.ContainerPort {
Name: StoragedPortNameHTTP,
ContainerPort: c.nc.Spec.Storaged.HTTPPort,
},
{
Name: StoragedPortNameHTTP2,
ContainerPort: c.nc.Spec.Storaged.HTTP2Port,
},
{
Name: StoragedPortNameAdmin,
ContainerPort: c.nc.Spec.Storaged.AdminPort,
},
}
}

Expand Down Expand Up @@ -384,3 +380,19 @@ func storageDataVolumeClaims(storageClaims []StorageClaim, componentType string)
}
return pvcs, nil
}

func (c *storagedComponent) IsDefaultThriftPort() bool {
return c.nc.Spec.Storaged.Port == defaultStoragedPortThrift
}

func (c *storagedComponent) GetThriftPort() int32 {
return c.nc.Spec.Storaged.Port
}

func (c *storagedComponent) IsDefaultHTTPPort() bool {
return c.nc.Spec.Storaged.HTTPPort == defaultStoragedPortHTTP
}

func (c *storagedComponent) GetHTTPPort() int32 {
return c.nc.Spec.Storaged.HTTPPort
}
16 changes: 0 additions & 16 deletions apis/apps/v1alpha1/nebulacluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -370,10 +370,6 @@ type GraphdSpec struct {
// +optional
// +kubebuilder:default=19669
HTTPPort int32 `json:"httpPort,omitempty"`

// +optional
// +kubebuilder:default=19670
HTTP2Port int32 `json:"http2Port,omitempty"`
}

// MetadSpec defines the desired state of Metad
Expand Down Expand Up @@ -408,10 +404,6 @@ type MetadSpec struct {
// +optional
// +kubebuilder:default=19559
HTTPPort int32 `json:"httpPort,omitempty"`

// +optional
// +kubebuilder:default=19560
HTTP2Port int32 `json:"http2Port,omitempty"`
}

// StoragedSpec defines the desired state of Storaged
Expand Down Expand Up @@ -453,14 +445,6 @@ type StoragedSpec struct {
// +optional
// +kubebuilder:default=19779
HTTPPort int32 `json:"httpPort,omitempty"`

// +optional
// +kubebuilder:default=19780
HTTP2Port int32 `json:"http2Port,omitempty"`

// +optional
// +kubebuilder:default=9778
AdminPort int32 `json:"adminPort,omitempty"`
}

// ComponentSpec is a common set of k8s resource configs for nebula components.
Expand Down
16 changes: 0 additions & 16 deletions config/crd/bases/apps.nebula-graph.io_nebulaclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3594,10 +3594,6 @@ spec:
- name
type: object
type: array
http2Port:
default: 19670
format: int32
type: integer
httpPort:
default: 19669
format: int32
Expand Down Expand Up @@ -6384,10 +6380,6 @@ spec:
- name
type: object
type: array
http2Port:
default: 19560
format: int32
type: integer
httpPort:
default: 19559
format: int32
Expand Down Expand Up @@ -8734,10 +8726,6 @@ spec:
type: object
storaged:
properties:
adminPort:
default: 9778
format: int32
type: integer
affinity:
properties:
nodeAffinity:
Expand Down Expand Up @@ -9219,10 +9207,6 @@ spec:
- name
type: object
type: array
http2Port:
default: 19780
format: int32
type: integer
httpPort:
default: 19779
format: int32
Expand Down

0 comments on commit d9b8fef

Please sign in to comment.