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

Release radix-api #681

Merged
merged 1 commit into from
Sep 27, 2024
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
25 changes: 23 additions & 2 deletions api/deployments/models/component_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/equinor/radix-api/api/secrets/suffix"
"github.com/equinor/radix-api/api/utils/secret"
"github.com/equinor/radix-common/utils/pointers"
"github.com/equinor/radix-common/utils/slice"
"github.com/equinor/radix-operator/pkg/apis/defaults"
"github.com/equinor/radix-operator/pkg/apis/deployment"
"github.com/equinor/radix-operator/pkg/apis/ingress"
Expand Down Expand Up @@ -55,6 +56,7 @@ type componentBuilder struct {
resources *radixv1.ResourceRequirements
runtime *radixv1.Runtime
replicasOverride *int
network *Network
}

func (b *componentBuilder) WithStatus(status ComponentStatus) ComponentBuilder {
Expand Down Expand Up @@ -106,8 +108,9 @@ func (b *componentBuilder) WithComponent(component radixv1.RadixCommonDeployComp
if component.GetPorts() != nil {
for _, port := range component.GetPorts() {
ports = append(ports, Port{
Name: port.Name,
Port: port.Port,
Name: port.Name,
Port: port.Port,
IsPublic: port.Name == component.GetPublicPort(),
})
}
}
Expand Down Expand Up @@ -176,6 +179,23 @@ func (b *componentBuilder) WithComponent(component radixv1.RadixCommonDeployComp
}

b.environmentVariables = component.GetEnvironmentVariables()

if network := component.GetNetwork(); network != nil {
b.network = &Network{}

if ingress := network.Ingress; ingress != nil {
b.network.Ingress = &Ingress{}

if publicIngress := ingress.Public; publicIngress != nil {
b.network.Ingress.Public = &IngressPublic{}

if allow := publicIngress.Allow; allow != nil {
b.network.Ingress.Public.Allow = slice.Map(*allow, func(v radixv1.IPOrCIDR) string { return string(v) })
}
}
}
}

return b
}

Expand Down Expand Up @@ -265,6 +285,7 @@ func (b *componentBuilder) BuildComponent() (*Component, error) {
CommitID: variables[defaults.RadixCommitHashEnvironmentVariable],
GitTags: variables[defaults.RadixGitTagsEnvironmentVariable],
Runtime: b.buildRuntimeModel(),
Network: b.network,
}
if b.resources != nil && (len(b.resources.Limits) > 0 || len(b.resources.Requests) > 0) {
component.Resources = pointers.Ptr(ConvertRadixResourceRequirements(*b.resources))
Expand Down
40 changes: 39 additions & 1 deletion api/deployments/models/component_deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,38 @@ type Component struct {

// Runtime requirements for the component or job
Runtime *Runtime `json:"runtime,omitempty"`

// Network configuration for the component
//
// required: false
Network *Network `json:"network,omitempty"`
}

// Network describes network configuration for a component
// swagger:model Network
type Network struct {
// Ingress configuration
//
// required: false
Ingress *Ingress `json:"ingress,omitempty"`
}

// Ingress describes ingress configuration for a component
// swagger:model Ingress
type Ingress struct {
// Public ingress configuration
//
// required: false
Public *IngressPublic `json:"public,omitempty"`
}

// IngressPublic describes public ingress configuration for a component
// swagger:model IngressPublic
type IngressPublic struct {
// List of allowed IP addresses or CIDRs. All traffic is allowed if list is empty.
//
// required: true
Allow []string `json:"allow"`
}

// ExternalDNS describes an external DNS entry for a component
Expand Down Expand Up @@ -236,9 +268,15 @@ type Port struct {

// Component port number. From radixconfig.yaml
//
// required: false
// required: true
// example: 8080
Port int32 `json:"port"`

// IsPublic indicates that the port is accessible from the Internet by proxying traffic from 443
//
// required: true
// example: true
IsPublic bool `json:"isPublic"`
}

// ComponentSummary describe a component part of a deployment
Expand Down
51 changes: 50 additions & 1 deletion swaggerui/html/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -5782,6 +5782,9 @@
"x-go-name": "Name",
"example": "server"
},
"network": {
"$ref": "#/definitions/Network"
},
"notifications": {
"$ref": "#/definitions/Notifications"
},
Expand Down Expand Up @@ -6664,6 +6667,34 @@
},
"x-go-package": "github.com/equinor/radix-api/api/privateimagehubs/models"
},
"Ingress": {
"description": "Ingress describes ingress configuration for a component",
"type": "object",
"properties": {
"public": {
"$ref": "#/definitions/IngressPublic"
}
},
"x-go-package": "github.com/equinor/radix-api/api/deployments/models"
},
"IngressPublic": {
"description": "IngressPublic describes public ingress configuration for a component",
"type": "object",
"required": [
"allow"
],
"properties": {
"allow": {
"description": "List of allowed IP addresses or CIDRs. All traffic is allowed if list is empty.",
"type": "array",
"items": {
"type": "string"
},
"x-go-name": "Allow"
}
},
"x-go-package": "github.com/equinor/radix-api/api/deployments/models"
},
"Job": {
"description": "Job holds general information about job",
"type": "object",
Expand Down Expand Up @@ -6922,6 +6953,16 @@
},
"x-go-package": "github.com/equinor/radix-api/api/jobs/models"
},
"Network": {
"description": "Network describes network configuration for a component",
"type": "object",
"properties": {
"ingress": {
"$ref": "#/definitions/Ingress"
}
},
"x-go-package": "github.com/equinor/radix-api/api/deployments/models"
},
"Node": {
"description": "Node Defines node attributes, where pod should be scheduled",
"type": "object",
Expand Down Expand Up @@ -7368,9 +7409,17 @@
"description": "Port describe a port of a component",
"type": "object",
"required": [
"name"
"name",
"port",
"isPublic"
],
"properties": {
"isPublic": {
"description": "IsPublic indicates that the port is accessible from the Internet by proxying traffic from 443",
"type": "boolean",
"x-go-name": "IsPublic",
"example": true
},
"name": {
"description": "Component port name. From radixconfig.yaml",
"type": "string",
Expand Down
Loading