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

Cluster provisioning part 1 #12

Merged
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
80 changes: 80 additions & 0 deletions charts/compute/crds/compute.unikorn-cloud.org_computeclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,22 @@ spec:
regionId:
description: Region to provision the cluster in.
type: string
tags:
description: Tags are aribrary user data.
items:
description: Tag is an arbirary key/value.
properties:
name:
description: Name of the tag.
type: string
value:
description: Value of the tag.
type: string
required:
- name
- value
type: object
type: array
workloadPools:
description: WorkloadPools defines the workload cluster topology.
properties:
Expand All @@ -104,6 +120,62 @@ spec:
This is irrelevant for baremetal machine flavors.
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
firewall:
description: Firewall is the workload pool firewall configuration.
properties:
ingress:
description: Ingress is a list of firewall rules applied
to a workload pool.
items:
properties:
cidr:
description: CIDR is the CIDR block to allow traffic
from.
pattern: ^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\/(?:3[0-2]|[1-2]?[0-9])$
type: string
id:
description: ID is the firewall rule identifier.
type: string
port:
description: Port is the port or range of ports.
properties:
number:
description: Number is the port number.
type: integer
range:
description: Range is the port range.
properties:
end:
description: End is the end of the range.
maximum: 65535
type: integer
start:
description: Start is the start of the
range.
minimum: 1
type: integer
required:
- end
- start
type: object
type: object
x-kubernetes-validations:
- message: at least one of number or range must
be defined
rule: (has(self.number) || has(self.range))
protocol:
description: Protocol The protocol to allow.
enum:
- tcp
- udp
type: string
required:
- cidr
- port
- protocol
type: object
type: array
type: object
flavorId:
description: Flavor is the regions service flavor to deploy
with.
Expand All @@ -115,6 +187,14 @@ spec:
name:
description: Name is the name of the pool.
type: string
publicIpAllocation:
description: PublicIPAllocation is the workload pool public
IP allocation configuration.
properties:
enabled:
description: Enabled is a flag to enable public IP allocation.
type: boolean
type: object
replicas:
default: 3
description: Replicas is the initial pool size to deploy.
Expand Down
9 changes: 9 additions & 0 deletions pkg/apis/unikorn/v1alpha1/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package v1alpha1

import (
"errors"
"fmt"

unikornv1core "github.com/unikorn-cloud/core/pkg/apis/unikorn/v1alpha1"
"github.com/unikorn-cloud/core/pkg/constants"
Expand Down Expand Up @@ -76,3 +77,11 @@ func (c *ComputeCluster) ResourceLabels() (labels.Set, error) {

return labels, nil
}

func (p *FirewallRulePort) String() string {
if p.Number != nil {
return fmt.Sprintf("%d", *p.Number)
}

return fmt.Sprintf("%d-%d", p.Range.Start, p.Range.End)
}
51 changes: 50 additions & 1 deletion pkg/apis/unikorn/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,56 @@ type ComputeWorkloadPoolSpec struct {
unikornv1core.MachineGeneric `json:",inline"`
// Name is the name of the pool.
Name string `json:"name"`
// PublicIPAllocation is the workload pool public IP allocation configuration.
PublicIPAllocation *PublicIPAllocationSpec `json:"publicIpAllocation,omitempty"`
// Firewall is the workload pool firewall configuration.
Firewall *FirewallSpec `json:"firewall,omitempty"`
}

type PublicIPAllocationSpec struct {
// Enabled is a flag to enable public IP allocation.
Enabled bool `json:"enabled,omitempty"`
}

type FirewallSpec struct {
// Ingress is a list of firewall rules applied to a workload pool.
Ingress []FirewallRule `json:"ingress,omitempty"`
}

type FirewallRule struct {
// ID is the firewall rule identifier.
ID string `json:"id,omitempty"`
// Protocol The protocol to allow.
Protocol FirewallRuleProtocol `json:"protocol"`
// CIDR is the CIDR block to allow traffic from.
CIDR unikornv1core.IPv4Prefix `json:"cidr"`
// Port is the port or range of ports.
Port FirewallRulePort `json:"port"`
}

// +kubebuilder:validation:Enum=tcp;udp
type FirewallRuleProtocol string

const (
TCP FirewallRuleProtocol = "tcp"
UDP FirewallRuleProtocol = "udp"
)

// +kubebuilder:validation:XValidation:message="at least one of number or range must be defined",rule=(has(self.number) || has(self.range))
type FirewallRulePort struct {
// Number is the port number.
Number *int `json:"number,omitempty"`
// Range is the port range.
Range *FirewallRulePortRange `json:"range,omitempty"`
}

type FirewallRulePortRange struct {
// Start is the start of the range.
// +kubebuilder:validation:Minimum=1
Start int `json:"start"`
// End is the end of the range.
// +kubebuilder:validation:Maximum=65535
End int `json:"end"`
}

// ComputeClusterList is a typed list of compute clusters.
Expand Down Expand Up @@ -85,7 +135,6 @@ type ComputeClusterWorkloadPoolsSpec struct {
type ComputeClusterStatus struct {
// Namespace defines the namespace a cluster resides in.
Namespace string `json:"namespace,omitempty"`

// Current service state of a Compute cluster.
Conditions []unikornv1core.Condition `json:"conditions,omitempty"`
}
109 changes: 109 additions & 0 deletions pkg/apis/unikorn/v1alpha1/zz_generated.deepcopy.go

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

Loading