Use compose-go https://github.com/compose-spec/compose-go to make Katenary parsing compose file the official way. Add labels: - `volume-from` (with `same-pod`) to avoid volume repetition - `ignore` to ignore a service - `mapenv` (replaces the `env-to-service`) to map environment to helm variable (as a template string) - `secret-vars` declares variables as secret values More: - Now, environment (as secret vars) are set in values.yaml - Ingress has got annotations in values.yaml - Probes (liveness probe) are improved - fixed code to optimize - many others fixes about path, bad volume check, refactorisation, tests...
52 lines
1.2 KiB
Go
52 lines
1.2 KiB
Go
package helm
|
|
|
|
// Service is a Kubernetes service.
|
|
type Service struct {
|
|
*K8sBase `yaml:",inline"`
|
|
Spec *ServiceSpec `yaml:"spec"`
|
|
}
|
|
|
|
// NewService creates a new initialized service.
|
|
func NewService(name string) *Service {
|
|
s := &Service{
|
|
K8sBase: NewBase(),
|
|
Spec: NewServiceSpec(),
|
|
}
|
|
s.K8sBase.Metadata.Name = ReleaseNameTpl + "-" + name
|
|
s.K8sBase.Kind = "Service"
|
|
s.K8sBase.ApiVersion = "v1"
|
|
s.K8sBase.Metadata.Labels[K+"/component"] = name
|
|
return s
|
|
}
|
|
|
|
// ServicePort is a port on a service.
|
|
type ServicePort struct {
|
|
Protocol string `yaml:"protocol"`
|
|
Port int `yaml:"port"`
|
|
TargetPort int `yaml:"targetPort"`
|
|
}
|
|
|
|
// NewServicePort creates a new initialized service port.
|
|
func NewServicePort(port, target int) *ServicePort {
|
|
return &ServicePort{
|
|
Protocol: "TCP",
|
|
Port: port,
|
|
TargetPort: port,
|
|
}
|
|
}
|
|
|
|
// ServiceSpec is the spec for a service.
|
|
type ServiceSpec struct {
|
|
Selector map[string]string
|
|
Ports []*ServicePort
|
|
Type string `yaml:"type,omitempty"`
|
|
}
|
|
|
|
// NewServiceSpec creates a new initialized service spec.
|
|
func NewServiceSpec() *ServiceSpec {
|
|
return &ServiceSpec{
|
|
Selector: make(map[string]string),
|
|
Ports: make([]*ServicePort, 0),
|
|
}
|
|
}
|