Skip to content

Commit

Permalink
Merge pull request #349 from makhov/clusterip-svc
Browse files Browse the repository at this point in the history
ClusterIP service support
  • Loading branch information
makhov authored Dec 7, 2023
2 parents 5fe172d + 3c3fe55 commit bd45fbd
Show file tree
Hide file tree
Showing 7 changed files with 371 additions and 61 deletions.
16 changes: 10 additions & 6 deletions api/k0smotron.io/v1beta1/k0smotroncluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ type ClusterSpec struct {
ExternalAddress string `json:"externalAddress,omitempty"`
// Service defines the service configuration.
//+kubebuilder:validation:Optional
//+kubebuilder:default={}
//+kubebuilder:default={"type":"ClusterIP","apiPort":30443,"konnectivityPort":30132}
Service ServiceSpec `json:"service,omitempty"`
// Persistence defines the persistence configuration. If empty k0smotron
// will use emptyDir as a volume.
Expand Down Expand Up @@ -97,7 +97,7 @@ type ClusterSpec struct {
Resources v1.ResourceRequirements `json:"resources,omitempty"`
}

// K0smotronClusterStatus defines the observed state of K0smotronCluster
// ClusterStatus defines the observed state of K0smotronCluster
type ClusterStatus struct {
ReconciliationStatus string `json:"reconciliationStatus"`
Ready bool `json:"ready,omitempty"`
Expand All @@ -119,8 +119,8 @@ type Cluster struct {
}

type ServiceSpec struct {
//+kubebuilder:validation:Enum=NodePort;LoadBalancer
//+kubebuilder:default=NodePort
//+kubebuilder:validation:Enum=ClusterIP;NodePort;LoadBalancer
//+kubebuilder:default=ClusterIP
Type v1.ServiceType `json:"type"`
// APIPort defines the kubernetes API port. If empty k0smotron
// will pick it automatically.
Expand Down Expand Up @@ -232,11 +232,15 @@ func (kmc *Cluster) GetConfigMapName() string {
return fmt.Sprintf("kmc-%s-config", kmc.Name)
}

func (kmc *Cluster) GetLoadBalancerName() string {
func (kmc *Cluster) GetServiceName() string {
return fmt.Sprintf("kmc-%s", kmc.Name)
}

func (kmc *Cluster) GetLoadBalancerServiceName() string {
return fmt.Sprintf("kmc-%s-lb", kmc.Name)
}

func (kmc *Cluster) GetNodePortName() string {
func (kmc *Cluster) GetNodePortServiceName() string {
return fmt.Sprintf("kmc-%s-nodeport", kmc.Name)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2091,6 +2091,10 @@ spec:
type: object
type: object
service:
default:
apiPort: 30443
konnectivityPort: 30132
type: ClusterIP
description: Service defines the service configuration.
properties:
annotations:
Expand All @@ -2110,10 +2114,11 @@ spec:
empty k0smotron will pick it automatically.
type: integer
type:
default: NodePort
default: ClusterIP
description: Service Type string describes ingress methods for
a service
enum:
- ClusterIP
- NodePort
- LoadBalancer
type: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2091,6 +2091,10 @@ spec:
type: object
type: object
service:
default:
apiPort: 30443
konnectivityPort: 30132
type: ClusterIP
description: Service defines the service configuration.
properties:
annotations:
Expand All @@ -2110,10 +2114,11 @@ spec:
empty k0smotron will pick it automatically.
type: integer
type:
default: NodePort
default: ClusterIP
description: Service Type string describes ingress methods for
a service
enum:
- ClusterIP
- NodePort
- LoadBalancer
type: string
Expand Down
9 changes: 7 additions & 2 deletions config/crd/bases/k0smotron.io_clusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2095,6 +2095,10 @@ spec:
type: object
type: object
service:
default:
apiPort: 30443
konnectivityPort: 30132
type: ClusterIP
description: Service defines the service configuration.
properties:
annotations:
Expand All @@ -2114,10 +2118,11 @@ spec:
empty k0smotron will pick it automatically.
type: integer
type:
default: NodePort
default: ClusterIP
description: Service Type string describes ingress methods for
a service
enum:
- ClusterIP
- NodePort
- LoadBalancer
type: string
Expand All @@ -2126,7 +2131,7 @@ spec:
type: object
type: object
status:
description: K0smotronClusterStatus defines the observed state of K0smotronCluster
description: ClusterStatus defines the observed state of K0smotronCluster
properties:
ready:
type: boolean
Expand Down
Loading

0 comments on commit bd45fbd

Please sign in to comment.