2
.gitignore
vendored
2
.gitignore
vendored
@@ -28,3 +28,5 @@ __pycache__
|
||||
|
||||
.rpmmacros
|
||||
*.gpg
|
||||
|
||||
katenary
|
||||
|
@@ -2,4 +2,5 @@ MD012: false
|
||||
MD013: false
|
||||
MD022: false
|
||||
MD033: false
|
||||
MD041: false
|
||||
MD046: false
|
||||
|
@@ -731,7 +731,7 @@ func (s *Secret) Yaml() ([]byte, error)
|
||||
Yaml returns the yaml representation of the secret.
|
||||
|
||||
<a name="Service"></a>
|
||||
## type [Service](<https://github.com/katenary/katenary/blob/develop/generator/service.go#L17-L20>)
|
||||
## type [Service](<https://github.com/katenary/katenary/blob/develop/generator/service.go#L18-L21>)
|
||||
|
||||
Service is a kubernetes Service.
|
||||
|
||||
@@ -743,7 +743,7 @@ type Service struct {
|
||||
```
|
||||
|
||||
<a name="NewService"></a>
|
||||
### func [NewService](<https://github.com/katenary/katenary/blob/develop/generator/service.go#L23>)
|
||||
### func [NewService](<https://github.com/katenary/katenary/blob/develop/generator/service.go#L24>)
|
||||
|
||||
```go
|
||||
func NewService(service types.ServiceConfig, appName string) *Service
|
||||
@@ -752,7 +752,7 @@ func NewService(service types.ServiceConfig, appName string) *Service
|
||||
NewService creates a new Service from a compose service.
|
||||
|
||||
<a name="Service.AddPort"></a>
|
||||
### func \(\*Service\) [AddPort](<https://github.com/katenary/katenary/blob/develop/generator/service.go#L52>)
|
||||
### func \(\*Service\) [AddPort](<https://github.com/katenary/katenary/blob/develop/generator/service.go#L53>)
|
||||
|
||||
```go
|
||||
func (s *Service) AddPort(port types.ServicePortConfig, serviceName ...string)
|
||||
@@ -761,7 +761,7 @@ func (s *Service) AddPort(port types.ServicePortConfig, serviceName ...string)
|
||||
AddPort adds a port to the service.
|
||||
|
||||
<a name="Service.Filename"></a>
|
||||
### func \(\*Service\) [Filename](<https://github.com/katenary/katenary/blob/develop/generator/service.go#L76>)
|
||||
### func \(\*Service\) [Filename](<https://github.com/katenary/katenary/blob/develop/generator/service.go#L78>)
|
||||
|
||||
```go
|
||||
func (s *Service) Filename() string
|
||||
@@ -770,7 +770,7 @@ func (s *Service) Filename() string
|
||||
Filename returns the filename of the service.
|
||||
|
||||
<a name="Service.Yaml"></a>
|
||||
### func \(\*Service\) [Yaml](<https://github.com/katenary/katenary/blob/develop/generator/service.go#L81>)
|
||||
### func \(\*Service\) [Yaml](<https://github.com/katenary/katenary/blob/develop/generator/service.go#L83>)
|
||||
|
||||
```go
|
||||
func (s *Service) Yaml() ([]byte, error)
|
||||
|
@@ -145,7 +145,7 @@ For more complete label usage, see [the labels page](labels.md).
|
||||
|
||||
### Work with Depends On?
|
||||
|
||||
Kubernetes does not provide service or pod starting detection from others pods. But katenary will create init containers
|
||||
Kubernetes does not provide service or pod starting detection from others pods. But Katenary will create `initContainer`
|
||||
to make you able to wait for a service to respond. But you'll probably need to adapt a bit the compose file.
|
||||
|
||||
See this compose file:
|
||||
|
@@ -5,3 +5,5 @@ pymdown-extensions==10.*
|
||||
mkdocs-material==9.*
|
||||
mkdocs-material-extensions==1.*
|
||||
mkdocs-plugin-inline-svg-mod
|
||||
beautifulsoup4==4.*
|
||||
mkdocs-manpage[preprocess]
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package generator
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"katenary/utils"
|
||||
"regexp"
|
||||
"strings"
|
||||
@@ -59,6 +60,7 @@ func (s *Service) AddPort(port types.ServicePortConfig, serviceName ...string) {
|
||||
|
||||
if targetPort := utils.GetServiceNameByPort(int(port.Target)); targetPort == "" {
|
||||
finalport = intstr.FromInt(int(port.Target))
|
||||
name = fmt.Sprintf("port-%d", port.Target)
|
||||
} else {
|
||||
finalport = intstr.FromString(targetPort)
|
||||
name = targetPort
|
||||
|
@@ -47,3 +47,37 @@ services:
|
||||
t.Errorf("Expected 2 ports, got %d", foundPort)
|
||||
}
|
||||
}
|
||||
|
||||
func TestWithSeveralUnknownPorts(t *testing.T) {
|
||||
composeFile := `
|
||||
services:
|
||||
multi:
|
||||
image: nginx
|
||||
ports:
|
||||
- 12443
|
||||
- 12480
|
||||
labels:
|
||||
katenary.v3/ingress: |-
|
||||
port: 12443
|
||||
`
|
||||
tmpDir := setup(composeFile)
|
||||
defer teardown(tmpDir)
|
||||
|
||||
currentDir, _ := os.Getwd()
|
||||
os.Chdir(tmpDir)
|
||||
defer os.Chdir(currentDir)
|
||||
|
||||
output := internalCompileTest(t, "-s", "templates/multi/service.yaml")
|
||||
service := v1.Service{}
|
||||
if err := yaml.Unmarshal([]byte(output), &service); err != nil {
|
||||
t.Errorf(unmarshalError, err)
|
||||
}
|
||||
|
||||
if len(service.Spec.Ports) != 2 {
|
||||
t.Errorf("Expected 2 ports, got %d", len(service.Spec.Ports))
|
||||
}
|
||||
// ensure that both port names are different
|
||||
if service.Spec.Ports[0].Name == service.Spec.Ports[1].Name {
|
||||
t.Errorf("Expected different port names, got %s and %s", service.Spec.Ports[0].Name, service.Spec.Ports[1].Name)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user