Skip to content
Open
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
4 changes: 4 additions & 0 deletions api/v1alpha1/stackitcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,12 @@ const (
// +kubebuilder:resource:path=stackitclusters,shortName=stic,scope=Namespaced,categories=cluster-api
// +kubebuilder:subresource:status
// +kubebuilder:printcolumn:name="Ready",type=boolean,JSONPath=".status.ready"
// +kubebuilder:printcolumn:name="Region",type=string,JSONPath=".spec.region"
// +kubebuilder:printcolumn:name="Endpoint",type=string,JSONPath=".status.apiServerEndpoint.host"
// +kubebuilder:printcolumn:name="Bastion IP",type=string,JSONPath=".status.bastion.publicIP"
// +kubebuilder:printcolumn:name="Age",type=date,JSONPath=".metadata.creationTimestamp"
// +kubebuilder:printcolumn:name="Network ID",type=string,JSONPath=".spec.network.id",priority=1
// +kubebuilder:printcolumn:name="Project ID",type=string,JSONPath=".spec.projectID",priority=1
// +kubebuilder:storageversion

// StackitCluster is the Schema for the stackitclusters API.
Expand Down
6 changes: 6 additions & 0 deletions api/v1alpha1/stackitclustertemplate_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ type StackitClusterTemplateResource struct {

// +kubebuilder:object:root=true
// +kubebuilder:resource:path=stackitclustertemplates,shortName=stict,scope=Namespaced,categories=cluster-api
// +kubebuilder:printcolumn:name="Region",type=string,JSONPath=".spec.template.spec.region"
// +kubebuilder:printcolumn:name="LB Enabled",type=boolean,JSONPath=".spec.template.spec.apiServerLoadBalancer.enabled"
// +kubebuilder:printcolumn:name="Bastion Enabled",type=boolean,JSONPath=".spec.template.spec.bastion.enabled"
// +kubebuilder:printcolumn:name="Age",type=date,JSONPath=".metadata.creationTimestamp"
// +kubebuilder:printcolumn:name="Network ID",type=string,JSONPath=".spec.template.spec.network.id",priority=1
// +kubebuilder:printcolumn:name="Project ID",type=string,JSONPath=".spec.template.spec.projectID",priority=1
// +kubebuilder:storageversion

// StackitClusterTemplate is the Schema for the stackitclustertemplates API.
Expand Down
11 changes: 11 additions & 0 deletions api/v1alpha1/stackitmachine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ type StackitMachineStatus struct {
// +optional
InstanceState string `json:"instanceState,omitempty"`

// availabilityZone is the STACKIT availability zone where the VM was placed.
// +optional
AvailabilityZone string `json:"availabilityZone,omitempty"`

// addresses contains the IP addresses associated with the VM.
// +optional
Addresses []clusterv1.MachineAddress `json:"addresses,omitempty"`
Expand Down Expand Up @@ -159,6 +163,13 @@ const (
// +kubebuilder:object:root=true
// +kubebuilder:resource:path=stackitmachines,shortName=stim,scope=Namespaced,categories=cluster-api
// +kubebuilder:subresource:status
// +kubebuilder:printcolumn:name="Cluster",type=string,JSONPath=".metadata.labels['cluster\\.x-k8s\\.io/cluster-name']",description="Cluster to which this resource belongs"
// +kubebuilder:printcolumn:name="Ready",type=boolean,JSONPath=".status.ready"
// +kubebuilder:printcolumn:name="State",type=string,JSONPath=".status.instanceState",description="STACKIT server state"
// +kubebuilder:printcolumn:name="Machine Type",type=string,JSONPath=".spec.machineType"
// +kubebuilder:printcolumn:name="IP",type=string,JSONPath=".status.addresses[?(@.type=='InternalIP')].address"
// +kubebuilder:printcolumn:name="Zone",type=string,JSONPath=".status.availabilityZone"
// +kubebuilder:printcolumn:name="Age",type=date,JSONPath=".metadata.creationTimestamp"
// +kubebuilder:storageversion

// StackitMachine is the Schema for the stackitmachines API.
Expand Down
6 changes: 6 additions & 0 deletions api/v1alpha1/stackitmachinetemplate_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ type StackitMachineTemplateResource struct {

// +kubebuilder:object:root=true
// +kubebuilder:resource:path=stackitmachinetemplates,shortName=stimt,scope=Namespaced,categories=cluster-api
// +kubebuilder:printcolumn:name="Machine Type",type=string,JSONPath=".spec.template.spec.machineType"
// +kubebuilder:printcolumn:name="Image ID",type=string,JSONPath=".spec.template.spec.imageID"
// +kubebuilder:printcolumn:name="Disk GiB",type=integer,JSONPath=".spec.template.spec.rootVolume.sizeGiB"
// +kubebuilder:printcolumn:name="Zone",type=string,JSONPath=".spec.template.spec.availabilityZone"
// +kubebuilder:printcolumn:name="Age",type=date,JSONPath=".metadata.creationTimestamp"
// +kubebuilder:printcolumn:name="Network ID",type=string,JSONPath=".spec.template.spec.network.id",priority=1
// +kubebuilder:storageversion

// StackitMachineTemplate is the Schema for the stackitmachinetemplates API.
Expand Down
11 changes: 8 additions & 3 deletions cloud/fake/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,15 @@ func (c *Client) CreateServer(_ context.Context, input cloud.CreateServerInput)
}

id := c.genID()
zone := input.AvailabilityZone
if zone == "" {
zone = "eu01-1"
}
server := &cloud.Server{
ID: id,
Name: input.Name,
State: "ACTIVE",
ID: id,
Name: input.Name,
State: "ACTIVE",
AvailabilityZone: zone,
Addresses: []cloud.Address{
{Type: "InternalIP", Address: "10.0.0.10"},
},
Expand Down
7 changes: 4 additions & 3 deletions cloud/sdk_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -962,9 +962,10 @@ func (c *SDKClient) serverFromSDK(ctx context.Context, server *iaas.Server) *Ser
return nil
}
out := &Server{
ID: server.GetId(),
Name: server.GetName(),
State: server.GetStatus(),
ID: server.GetId(),
Name: server.GetName(),
State: server.GetStatus(),
AvailabilityZone: server.GetAvailabilityZone(),
}
nics, err := c.iaasClient.DefaultAPI.ListServerNICs(ctx, c.projectID, c.region, out.ID).Execute()
if err == nil {
Expand Down
11 changes: 6 additions & 5 deletions cloud/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ package cloud

// Server describes a STACKIT compute instance in provider-neutral terms.
type Server struct {
ID string
Name string
State string
ProviderID string
Addresses []Address
ID string
Name string
State string
ProviderID string
AvailabilityZone string
Addresses []Address
}

// Address is an IP or DNS endpoint of a Server.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,26 @@ spec:
- jsonPath: .status.ready
name: Ready
type: boolean
- jsonPath: .spec.region
name: Region
type: string
- jsonPath: .status.apiServerEndpoint.host
name: Endpoint
type: string
- jsonPath: .status.bastion.publicIP
name: Bastion IP
type: string
- jsonPath: .metadata.creationTimestamp
name: Age
type: date
- jsonPath: .spec.network.id
name: Network ID
priority: 1
type: string
- jsonPath: .spec.projectID
name: Project ID
priority: 1
type: string
name: v1alpha1
schema:
openAPIV3Schema:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,28 @@ spec:
singular: stackitclustertemplate
scope: Namespaced
versions:
- name: v1alpha1
- additionalPrinterColumns:
- jsonPath: .spec.template.spec.region
name: Region
type: string
- jsonPath: .spec.template.spec.apiServerLoadBalancer.enabled
name: LB Enabled
type: boolean
- jsonPath: .spec.template.spec.bastion.enabled
name: Bastion Enabled
type: boolean
- jsonPath: .metadata.creationTimestamp
name: Age
type: date
- jsonPath: .spec.template.spec.network.id
name: Network ID
priority: 1
type: string
- jsonPath: .spec.template.spec.projectID
name: Project ID
priority: 1
type: string
name: v1alpha1
schema:
openAPIV3Schema:
description: StackitClusterTemplate is the Schema for the stackitclustertemplates
Expand Down Expand Up @@ -274,3 +295,4 @@ spec:
type: object
served: true
storage: true
subresources: {}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,31 @@ spec:
singular: stackitmachine
scope: Namespaced
versions:
- name: v1alpha1
- additionalPrinterColumns:
- description: Cluster to which this resource belongs
jsonPath: .metadata.labels['cluster\.x-k8s\.io/cluster-name']
name: Cluster
type: string
- jsonPath: .status.ready
name: Ready
type: boolean
- description: STACKIT server state
jsonPath: .status.instanceState
name: State
type: string
- jsonPath: .spec.machineType
name: Machine Type
type: string
- jsonPath: .status.addresses[?(@.type=='InternalIP')].address
name: IP
type: string
- jsonPath: .status.availabilityZone
name: Zone
type: string
- jsonPath: .metadata.creationTimestamp
name: Age
type: date
name: v1alpha1
schema:
openAPIV3Schema:
description: StackitMachine is the Schema for the stackitmachines API.
Expand Down Expand Up @@ -150,6 +174,10 @@ spec:
- type
type: object
type: array
availabilityZone:
description: availabilityZone is the STACKIT availability zone where
the VM was placed.
type: string
conditions:
description: conditions represent the current state of the StackitMachine
resource.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,27 @@ spec:
singular: stackitmachinetemplate
scope: Namespaced
versions:
- name: v1alpha1
- additionalPrinterColumns:
- jsonPath: .spec.template.spec.machineType
name: Machine Type
type: string
- jsonPath: .spec.template.spec.imageID
name: Image ID
type: string
- jsonPath: .spec.template.spec.rootVolume.sizeGiB
name: Disk GiB
type: integer
- jsonPath: .spec.template.spec.availabilityZone
name: Zone
type: string
- jsonPath: .metadata.creationTimestamp
name: Age
type: date
- jsonPath: .spec.template.spec.network.id
name: Network ID
priority: 1
type: string
name: v1alpha1
schema:
openAPIV3Schema:
description: StackitMachineTemplate is the Schema for the stackitmachinetemplates
Expand Down Expand Up @@ -168,3 +188,4 @@ spec:
type: object
served: true
storage: true
subresources: {}
1 change: 1 addition & 0 deletions controller/stackitmachine_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ var _ = Describe("StackitMachine Controller", func() {
Expect(got.Status.Ready).To(BeTrue())
Expect(got.Status.InstanceID).NotTo(BeEmpty())
Expect(got.Status.InstanceState).To(Equal("ACTIVE"))
Expect(got.Status.AvailabilityZone).To(Equal("eu01-1"))
Expect(got.Status.ProviderID).To(Equal("stackit://" + got.Status.InstanceID))
Expect(got.Spec.ProviderID).NotTo(BeNil())
Expect(*got.Spec.ProviderID).To(Equal(got.Status.ProviderID))
Expand Down
2 changes: 2 additions & 0 deletions scope/machine_scope.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ func (s *MachineScope) SetInstance(server *cloud.Server) string {
providerID := cloud.NewProviderID(s.StackitCluster.Spec.ProjectID, s.StackitCluster.Spec.Region, server.ID)
s.StackitMachine.Status.InstanceID = server.ID
s.StackitMachine.Status.InstanceState = server.State
s.StackitMachine.Status.AvailabilityZone = server.AvailabilityZone
s.StackitMachine.Spec.ProviderID = &providerID
s.StackitMachine.Status.ProviderID = providerID
s.StackitMachine.Status.Initialization.Provisioned = true
Expand All @@ -106,4 +107,5 @@ func (s *MachineScope) SetInstance(server *cloud.Server) string {
func (s *MachineScope) ClearInstance() {
s.StackitMachine.Status.InstanceID = ""
s.StackitMachine.Status.InstanceState = ""
s.StackitMachine.Status.AvailabilityZone = ""
}
Loading