forked from LaconicNetwork/kompose
Add kompose.service.expose.tls-secret
This commit is contained in:
committed by
Oliver Bristow
parent
e4adfef9cb
commit
35a782024d
+43
-42
@@ -62,48 +62,49 @@ type ConvertOptions struct {
|
||||
|
||||
// ServiceConfig holds the basic struct of a container
|
||||
type ServiceConfig struct {
|
||||
ContainerName string
|
||||
Image string `compose:"image"`
|
||||
Environment []EnvVar `compose:"environment"`
|
||||
EnvFile []string `compose:"env_file"`
|
||||
Port []Ports `compose:"ports"`
|
||||
Command []string `compose:"command"`
|
||||
WorkingDir string `compose:""`
|
||||
Args []string `compose:"args"`
|
||||
VolList []string `compose:"volumes"`
|
||||
Network []string `compose:"network"`
|
||||
Labels map[string]string `compose:"labels"`
|
||||
Annotations map[string]string `compose:""`
|
||||
CPUSet string `compose:"cpuset"`
|
||||
CPUShares int64 `compose:"cpu_shares"`
|
||||
CPUQuota int64 `compose:"cpu_quota"`
|
||||
CPULimit int64 `compose:""`
|
||||
CPUReservation int64 `compose:""`
|
||||
CapAdd []string `compose:"cap_add"`
|
||||
CapDrop []string `compose:"cap_drop"`
|
||||
Expose []string `compose:"expose"`
|
||||
Pid string `compose:"pid"`
|
||||
Privileged bool `compose:"privileged"`
|
||||
Restart string `compose:"restart"`
|
||||
User string `compose:"user"`
|
||||
VolumesFrom []string `compose:"volumes_from"`
|
||||
ServiceType string `compose:"kompose.service.type"`
|
||||
StopGracePeriod string `compose:"stop_grace_period"`
|
||||
Build string `compose:"build"`
|
||||
BuildArgs map[string]*string `compose:"build-args"`
|
||||
ExposeService string `compose:"kompose.service.expose"`
|
||||
Stdin bool `compose:"stdin_open"`
|
||||
Tty bool `compose:"tty"`
|
||||
MemLimit yaml.MemStringorInt `compose:"mem_limit"`
|
||||
MemReservation yaml.MemStringorInt `compose:""`
|
||||
DeployMode string `compose:""`
|
||||
TmpFs []string `compose:"tmpfs"`
|
||||
Dockerfile string `compose:"dockerfile"`
|
||||
Replicas int `compose:"replicas"`
|
||||
GroupAdd []int64 `compose:"group_add"`
|
||||
Volumes []Volumes `compose:""`
|
||||
HealthChecks HealthCheck `compose:""`
|
||||
Placement map[string]string `compose:""`
|
||||
ContainerName string
|
||||
Image string `compose:"image"`
|
||||
Environment []EnvVar `compose:"environment"`
|
||||
EnvFile []string `compose:"env_file"`
|
||||
Port []Ports `compose:"ports"`
|
||||
Command []string `compose:"command"`
|
||||
WorkingDir string `compose:""`
|
||||
Args []string `compose:"args"`
|
||||
VolList []string `compose:"volumes"`
|
||||
Network []string `compose:"network"`
|
||||
Labels map[string]string `compose:"labels"`
|
||||
Annotations map[string]string `compose:""`
|
||||
CPUSet string `compose:"cpuset"`
|
||||
CPUShares int64 `compose:"cpu_shares"`
|
||||
CPUQuota int64 `compose:"cpu_quota"`
|
||||
CPULimit int64 `compose:""`
|
||||
CPUReservation int64 `compose:""`
|
||||
CapAdd []string `compose:"cap_add"`
|
||||
CapDrop []string `compose:"cap_drop"`
|
||||
Expose []string `compose:"expose"`
|
||||
Pid string `compose:"pid"`
|
||||
Privileged bool `compose:"privileged"`
|
||||
Restart string `compose:"restart"`
|
||||
User string `compose:"user"`
|
||||
VolumesFrom []string `compose:"volumes_from"`
|
||||
ServiceType string `compose:"kompose.service.type"`
|
||||
StopGracePeriod string `compose:"stop_grace_period"`
|
||||
Build string `compose:"build"`
|
||||
BuildArgs map[string]*string `compose:"build-args"`
|
||||
ExposeService string `compose:"kompose.service.expose"`
|
||||
ExposeServiceTLS string `compose:"kompose.service.expose.tls-secret"`
|
||||
Stdin bool `compose:"stdin_open"`
|
||||
Tty bool `compose:"tty"`
|
||||
MemLimit yaml.MemStringorInt `compose:"mem_limit"`
|
||||
MemReservation yaml.MemStringorInt `compose:""`
|
||||
DeployMode string `compose:""`
|
||||
TmpFs []string `compose:"tmpfs"`
|
||||
Dockerfile string `compose:"dockerfile"`
|
||||
Replicas int `compose:"replicas"`
|
||||
GroupAdd []int64 `compose:"group_add"`
|
||||
Volumes []Volumes `compose:""`
|
||||
HealthChecks HealthCheck `compose:""`
|
||||
Placement map[string]string `compose:""`
|
||||
}
|
||||
|
||||
// HealthCheck the healthcheck configuration for a service
|
||||
|
||||
@@ -241,8 +241,13 @@ func libComposeToKomposeMapping(composeObject *project.Project) (kobject.Kompose
|
||||
serviceConfig.ServiceType = serviceType
|
||||
case "kompose.service.expose":
|
||||
serviceConfig.ExposeService = strings.ToLower(value)
|
||||
case "kompose.service.expose.tls-secret":
|
||||
serviceConfig.ExposeServiceTLS = value
|
||||
}
|
||||
}
|
||||
if serviceConfig.ExposeService == "" && serviceConfig.ExposeServiceTLS != "" {
|
||||
return kobject.KomposeObject{}, errors.New("kompose.service.expose.tls-secret was specifed without kompose.service.expose")
|
||||
}
|
||||
err = checkLabelsPorts(len(serviceConfig.Port), composeServiceConfig.Labels["kompose.service.type"], name)
|
||||
if err != nil {
|
||||
return kobject.KomposeObject{}, errors.Wrap(err, "kompose.service.type can't be set if service doesn't expose any ports.")
|
||||
|
||||
@@ -351,9 +351,15 @@ func dockerComposeToKomposeMapping(composeObject *types.Config) (kobject.Kompose
|
||||
serviceConfig.ServiceType = serviceType
|
||||
case "kompose.service.expose":
|
||||
serviceConfig.ExposeService = strings.ToLower(value)
|
||||
case "kompose.service.expose.tls-secret":
|
||||
serviceConfig.ExposeServiceTLS = value
|
||||
}
|
||||
}
|
||||
|
||||
if serviceConfig.ExposeService == "" && serviceConfig.ExposeServiceTLS != "" {
|
||||
return kobject.KomposeObject{}, errors.New("kompose.service.expose.tls-secret was specifed without kompose.service.expose")
|
||||
}
|
||||
|
||||
// Log if the name will been changed
|
||||
if normalizeServiceNames(name) != name {
|
||||
log.Infof("Service name in docker-compose has been changed from %q to %q", name, normalizeServiceNames(name))
|
||||
|
||||
@@ -262,6 +262,16 @@ func (k *Kubernetes) initIngress(name string, service kobject.ServiceConfig, por
|
||||
if service.ExposeService != "true" {
|
||||
ingress.Spec.Rules[0].Host = service.ExposeService
|
||||
}
|
||||
if service.ExposeServiceTLS != "" {
|
||||
ingress.Spec.TLS = []extensions.IngressTLS{
|
||||
{
|
||||
Hosts: []string{
|
||||
service.ExposeService,
|
||||
},
|
||||
SecretName: service.ExposeServiceTLS,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
return ingress
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user