forked from LaconicNetwork/kompose
Add kompose.service.expose.ingress-class-name (#1486)
Signed-off-by: Sergey Shevchenko <shevchenko@simple.life>
This commit is contained in:
parent
8e94728ddb
commit
98578640c0
@ -182,6 +182,7 @@ The currently supported options are:
|
||||
| kompose.service.expose | true / hostnames (separated by comma) |
|
||||
| kompose.service.nodeport.port | port value (string) |
|
||||
| kompose.service.expose.tls-secret | secret name |
|
||||
| kompose.service.expose.ingress-class-name | ingress class name |
|
||||
| kompose.volume.size | kubernetes supported volume size |
|
||||
| kompose.volume.storage-class-name | kubernetes supported volume storageClassName |
|
||||
| kompose.volume.type | use k8s volume type, eg "configMap", "persistentVolumeClaim", "emptyDir", "hostPath" |
|
||||
@ -250,6 +251,7 @@ services:
|
||||
- For the OpenShift provider, a route is created.
|
||||
- `kompose.service.nodeport.port` defines the port value when service type is `nodeport`, this label should only be set when the service only contains 1 port. Usually kubernetes define a port range for node port values, kompose will not validate this.
|
||||
- `kompose.service.expose.tls-secret` provides the name of the TLS secret to use with the Kubernetes ingress controller. This requires kompose.service.expose to be set.
|
||||
- `kompose.service.expose.ingress-class-name` provides the name of ingress class to use with the Kubernetes ingress controller. This requires kompose.service.
|
||||
|
||||
For example:
|
||||
|
||||
@ -265,6 +267,7 @@ services:
|
||||
labels:
|
||||
kompose.service.expose: "counter.example.com,foobar.example.com"
|
||||
kompose.service.expose.tls-secret: "example-secret"
|
||||
kompose.service.expose.ingress-class-name: "nginx"
|
||||
redis:
|
||||
image: redis:3.0
|
||||
ports:
|
||||
|
||||
@ -132,6 +132,7 @@ type ServiceConfig struct {
|
||||
ExposeServicePath string `compose:"kompose.service.expose.path"`
|
||||
BuildLabels map[string]string `compose:"build-labels"`
|
||||
ExposeServiceTLS string `compose:"kompose.service.expose.tls-secret"`
|
||||
ExposeServiceIngressClassName *string `compose:"kompose.service.expose.ingress-class-name"`
|
||||
ImagePullSecret string `compose:"kompose.image-pull-secret"`
|
||||
Stdin bool `compose:"stdin_open"`
|
||||
Tty bool `compose:"tty"`
|
||||
|
||||
@ -40,6 +40,8 @@ const (
|
||||
LabelServiceExpose = "kompose.service.expose"
|
||||
// LabelServiceExposeTLSSecret provides the name of the TLS secret to use with the Kubernetes ingress controller
|
||||
LabelServiceExposeTLSSecret = "kompose.service.expose.tls-secret"
|
||||
// LabelServiceExposeIngressClassName provides the name of ingress class to use with the Kubernetes ingress controller
|
||||
LabelServiceExposeIngressClassName = "kompose.service.expose.ingress-class-name"
|
||||
// LabelServiceAccountName defines the service account name to provide the credential info of the pod.
|
||||
LabelServiceAccountName = "kompose.serviceaccount-name"
|
||||
// LabelControllerType defines the type of controller to be created
|
||||
|
||||
@ -658,6 +658,8 @@ func parseKomposeLabels(labels map[string]string, serviceConfig *kobject.Service
|
||||
serviceConfig.NodePortPort = cast.ToInt32(value)
|
||||
case LabelServiceExposeTLSSecret:
|
||||
serviceConfig.ExposeServiceTLS = value
|
||||
case LabelServiceExposeIngressClassName:
|
||||
serviceConfig.ExposeServiceIngressClassName = &value
|
||||
case LabelImagePullSecret:
|
||||
serviceConfig.ImagePullSecret = value
|
||||
case LabelImagePullPolicy:
|
||||
@ -671,6 +673,10 @@ func parseKomposeLabels(labels map[string]string, serviceConfig *kobject.Service
|
||||
return errors.New("kompose.service.expose.tls-secret was specified without kompose.service.expose")
|
||||
}
|
||||
|
||||
if serviceConfig.ExposeService == "" && serviceConfig.ExposeServiceIngressClassName != nil {
|
||||
return errors.New("kompose.service.expose.ingress-class-name was specified without kompose.service.expose")
|
||||
}
|
||||
|
||||
if serviceConfig.ServiceType != string(api.ServiceTypeNodePort) && serviceConfig.NodePortPort != 0 {
|
||||
return errors.New("kompose.service.type must be nodeport when assign node port value")
|
||||
}
|
||||
|
||||
@ -525,6 +525,10 @@ func (k *Kubernetes) initIngress(name string, service kobject.ServiceConfig, por
|
||||
}
|
||||
}
|
||||
|
||||
if service.ExposeServiceIngressClassName != nil {
|
||||
ingress.Spec.IngressClassName = service.ExposeServiceIngressClassName
|
||||
}
|
||||
|
||||
return ingress
|
||||
}
|
||||
|
||||
|
||||
1
script/test/fixtures/expose/compose.yaml
vendored
1
script/test/fixtures/expose/compose.yaml
vendored
@ -7,6 +7,7 @@ web:
|
||||
labels:
|
||||
kompose.service.expose: "batman.example.com/dev,batwoman.example.com"
|
||||
kompose.service.expose.tls-secret: "test-secret"
|
||||
kompose.service.expose.ingress-class-name: "nginx"
|
||||
redis:
|
||||
image: redis:3.0
|
||||
ports:
|
||||
|
||||
5
script/test/fixtures/expose/output-k8s.json
vendored
5
script/test/fixtures/expose/output-k8s.json
vendored
@ -40,6 +40,7 @@
|
||||
},
|
||||
"annotations": {
|
||||
"kompose.service.expose": "batman.example.com/dev,batwoman.example.com",
|
||||
"kompose.service.expose.ingress-class-name": "nginx",
|
||||
"kompose.service.expose.tls-secret": "test-secret"
|
||||
}
|
||||
},
|
||||
@ -114,6 +115,7 @@
|
||||
},
|
||||
"annotations": {
|
||||
"kompose.service.expose": "batman.example.com/dev,batwoman.example.com",
|
||||
"kompose.service.expose.ingress-class-name": "nginx",
|
||||
"kompose.service.expose.tls-secret": "test-secret"
|
||||
}
|
||||
},
|
||||
@ -132,6 +134,7 @@
|
||||
},
|
||||
"annotations": {
|
||||
"kompose.service.expose": "batman.example.com/dev,batwoman.example.com",
|
||||
"kompose.service.expose.ingress-class-name": "nginx",
|
||||
"kompose.service.expose.tls-secret": "test-secret"
|
||||
}
|
||||
},
|
||||
@ -166,10 +169,12 @@
|
||||
},
|
||||
"annotations": {
|
||||
"kompose.service.expose": "batman.example.com/dev,batwoman.example.com",
|
||||
"kompose.service.expose.ingress-class-name": "nginx",
|
||||
"kompose.service.expose.tls-secret": "test-secret"
|
||||
}
|
||||
},
|
||||
"spec": {
|
||||
"ingressClassName": "nginx",
|
||||
"tls": [
|
||||
{
|
||||
"hosts": [
|
||||
|
||||
2
script/test/fixtures/expose/output-ocp.json
vendored
2
script/test/fixtures/expose/output-ocp.json
vendored
@ -40,6 +40,7 @@
|
||||
},
|
||||
"annotations": {
|
||||
"kompose.service.expose": "batman.example.com/dev,batwoman.example.com",
|
||||
"kompose.service.expose.ingress-class-name": "nginx",
|
||||
"kompose.service.expose.tls-secret": "test-secret"
|
||||
}
|
||||
},
|
||||
@ -174,6 +175,7 @@
|
||||
},
|
||||
"annotations": {
|
||||
"kompose.service.expose": "batman.example.com/dev,batwoman.example.com",
|
||||
"kompose.service.expose.ingress-class-name": "nginx",
|
||||
"kompose.service.expose.tls-secret": "test-secret"
|
||||
}
|
||||
},
|
||||
|
||||
Loading…
Reference in New Issue
Block a user