Skip to content
Closed
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
16 changes: 11 additions & 5 deletions internal/server/submit/conversion/conversions.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ func createIngressFromService(
serviceName, namespace, jobId string,
) *armadaevents.KubernetesObject {
rules := make([]networking.IngressRule, 0, len(service.Ports))
tlsHosts := make([]string, 0, len(service.Ports))
tlsHosts := ingressConfig.TlsHosts

// Rest of the hosts are generated off port information
for _, servicePort := range service.Ports {
Expand Down Expand Up @@ -220,17 +220,23 @@ func createIngressFromService(
})
}

ingressSpec := &networking.IngressSpec{
Rules: rules,
TLS: tls,
}

if len(ingressConfig.ClassName) > 0 {
ingressSpec.IngressClassName = &ingressConfig.ClassName
}

return &armadaevents.KubernetesObject{
ObjectMeta: &armadaevents.ObjectMeta{
Name: fmt.Sprintf("%s-ingress-%d", common.PodName(jobId), serviceIdx),
Annotations: util.MergeMaps(map[string]string{}, ingressConfig.Annotations),
Labels: map[string]string{},
},
Object: &armadaevents.KubernetesObject_Ingress{
Ingress: &networking.IngressSpec{
Rules: rules,
TLS: tls,
},
Ingress: ingressSpec,
},
}
}
Expand Down
24 changes: 23 additions & 1 deletion internal/server/submit/conversion/conversions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,8 @@ func TestCreateIngressFromService(t *testing.T) {
Type: v1.ServiceTypeClusterIP,
}

nginxIngressClassName := "nginx"

defaultIngressRule := networking.IngressRule{
Host: "testContainer-8080-armada-00000000000000000000000001-0.testNamespace.",
IngressRuleValue: networking.IngressRuleValue{
Expand Down Expand Up @@ -261,6 +263,25 @@ func TestCreateIngressFromService(t *testing.T) {
},
},
},
"ingressWithCustomClassName": {
ingressConfig: &api.IngressConfig{
ClassName: nginxIngressClassName,
},
expectedIngress: &armadaevents.KubernetesObject{
ObjectMeta: &armadaevents.ObjectMeta{
Name: "armada-00000000000000000000000001-0-ingress-1",
Annotations: map[string]string{},
Labels: map[string]string{},
},
Object: &armadaevents.KubernetesObject_Ingress{
Ingress: &networking.IngressSpec{
IngressClassName: &nginxIngressClassName,
TLS: []networking.IngressTLS{},
Rules: []networking.IngressRule{defaultIngressRule},
},
},
},
},
"ingressWithDefaultTls": {
ingressConfig: &api.IngressConfig{
TlsEnabled: true,
Expand Down Expand Up @@ -288,6 +309,7 @@ func TestCreateIngressFromService(t *testing.T) {
ingressConfig: &api.IngressConfig{
TlsEnabled: true,
CertName: "testCustomCert",
TlsHosts: []string{"example.com"},
},
expectedIngress: &armadaevents.KubernetesObject{
ObjectMeta: &armadaevents.ObjectMeta{
Expand All @@ -299,7 +321,7 @@ func TestCreateIngressFromService(t *testing.T) {
Ingress: &networking.IngressSpec{
TLS: []networking.IngressTLS{
{
Hosts: []string{"testContainer-8080-armada-00000000000000000000000001-0.testNamespace."},
Hosts: []string{"example.com", "testContainer-8080-armada-00000000000000000000000001-0.testNamespace."},
SecretName: "testCustomCert",
},
},
Expand Down
9 changes: 9 additions & 0 deletions pkg/api/api.swagger.go
Original file line number Diff line number Diff line change
Expand Up @@ -809,6 +809,9 @@ func SwaggerJsonTemplate() string {
" \"certName\": {\n" +
" \"type\": \"string\"\n" +
" },\n" +
" \"className\": {\n" +
" \"type\": \"string\"\n" +
" },\n" +
" \"ports\": {\n" +
" \"type\": \"array\",\n" +
" \"items\": {\n" +
Expand All @@ -819,6 +822,12 @@ func SwaggerJsonTemplate() string {
" \"tlsEnabled\": {\n" +
" \"type\": \"boolean\"\n" +
" },\n" +
" \"tlsHosts\": {\n" +
" \"type\": \"array\",\n" +
" \"items\": {\n" +
" \"type\": \"string\"\n" +
" }\n" +
" },\n" +
" \"type\": {\n" +
" \"$ref\": \"#/definitions/apiIngressType\"\n" +
" },\n" +
Expand Down
9 changes: 9 additions & 0 deletions pkg/api/api.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -798,6 +798,9 @@
"certName": {
"type": "string"
},
"className": {
"type": "string"
},
"ports": {
"type": "array",
"items": {
Expand All @@ -808,6 +811,12 @@
"tlsEnabled": {
"type": "boolean"
},
"tlsHosts": {
"type": "array",
"items": {
"type": "string"
}
},
"type": {
"$ref": "#/definitions/apiIngressType"
},
Expand Down
Loading
Loading