Skip to content
This repository was archived by the owner on Feb 19, 2025. It is now read-only.

Commit 9a193d6

Browse files
authored
van api (#6)
* updates for client api * work with errors * service interface updates, expose host * restructure controller * update controller pipeline * sasl config
1 parent 33758b9 commit 9a193d6

37 files changed

Lines changed: 3619 additions & 2240 deletions

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ COPY . .
55

66
RUN go mod download
77

8-
RUN go build -o controller cmd/skupper-docker-controller/main.go
8+
RUN go build -o controller cmd/skupper-docker-controller/main.go cmd/skupper-docker-controller/controller.go cmd/skupper-docker-controller/service_sync.go
99

1010
CMD ["/go/src/app/controller"]

Makefile

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ IMAGE := quay.io/skupper/skupper-docker-controller
44
all: build-cmd build-controller
55

66
build-cmd:
7-
go build -ldflags="-X main.version=${VERSION}" -o skupper-docker cmd/skupper-docker-cli/main.go
7+
go build -ldflags="-X main.version=${VERSION}" -o skupper-docker cmd/skupper-docker/main.go
88

99
build-controller:
10-
go build -ldflags="-X main.version=${VERSION}" -o skupper-docker-controller cmd/skupper-docker-controller/main.go
10+
go build -ldflags="-X main.version=${VERSION}" -o skupper-docker-controller cmd/skupper-docker-controller/main.go cmd/skupper-docker-controller/controller.go cmd/skupper-docker-controller/service_sync.go
1111

1212
docker-build:
1313
docker build -t ${IMAGE} .
@@ -23,17 +23,17 @@ package: release/windows.zip release/darwin.zip release/linux.tgz
2323
release/linux.tgz: release/linux/skupper-docker
2424
tar -czf release/linux.tgz -C release/linux/ skupper-docker
2525

26-
release/linux/skupper-docker: cmd/skupper-docker-cli/main.go
27-
GOOS=linux GOARCH=amd64 go build -ldflags="-X main.version=${VERSION}" -o release/linux/skupper-docker cmd/skupper-docker-cli/main.go
26+
release/linux/skupper-docker: cmd/skupper-docker/main.go
27+
GOOS=linux GOARCH=amd64 go build -ldflags="-X main.version=${VERSION}" -o release/linux/skupper-docker cmd/skupper-docker/main.go
2828

29-
release/windows/skupper-docker: cmd/skupper-docker-cli/main.go
30-
GOOS=windows GOARCH=amd64 go build -ldflags="-X main.version=${VERSION}" -o release/windows/skupper-docker cmd/skupper-docker-cli/main.go
29+
release/windows/skupper-docker: cmd/skupper-docker/main.go
30+
GOOS=windows GOARCH=amd64 go build -ldflags="-X main.version=${VERSION}" -o release/windows/skupper-docker cmd/skupper-docker/main.go
3131

3232
release/windows.zip: release/windows/skupper-docker
3333
zip -j release/windows.zip release/windows/skupper-docker
3434

35-
release/darwin/skupper-docker: cmd/skupper-docker-cli/main.go
36-
GOOS=darwin GOARCH=amd64 go build -ldflags="-X main.version=${VERSION}" -o release/darwin/skupper-docker cmd/skupper-docker-cli/main.go
35+
release/darwin/skupper-docker: cmd/skupper-docker/main.go
36+
GOOS=darwin GOARCH=amd64 go build -ldflags="-X main.version=${VERSION}" -o release/darwin/skupper-docker cmd/skupper-docker/main.go
3737

3838
release/darwin.zip: release/darwin/skupper-docker
3939
zip -j release/darwin.zip release/darwin/skupper-docker

api/types/client.go

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package types
2+
3+
type VanConnectorCreateOptions struct {
4+
Name string
5+
Cost int32
6+
}
7+
8+
type VanRouterCreateOptions struct {
9+
SkupperName string
10+
IsEdge bool
11+
EnableController bool
12+
EnableServiceSync bool
13+
EnableConsole bool
14+
AuthMode string
15+
User string
16+
Password string
17+
ClusterLocal bool
18+
Replicas int32
19+
}
20+
21+
type VanServiceInterfaceCreateOptions struct {
22+
Protocol string
23+
Address string
24+
Port int
25+
TargetPort int
26+
Headless bool
27+
}
28+
29+
type VanServiceInterfaceRemoveOptions struct {
30+
Address string
31+
}
32+
33+
type VanRouterInspectResponse struct {
34+
Status VanRouterStatusSpec
35+
TransportVersion string
36+
ControllerVersion string
37+
ExposedServices int
38+
}
39+
40+
type VanConnectorInspectResponse struct {
41+
Connector *Connector
42+
Connected bool
43+
}
44+
45+
type VanRouterStatusSpec struct {
46+
Mode string `json:"mode,omitempty"`
47+
TransportReadyReplicas int32 `json:"transportReadyReplicas,omitempty"`
48+
ConnectedSites TransportConnectedSites `json:"connectedSites,omitempty"`
49+
BindingsCount int `json:"bindingsCount,omitempty"`
50+
}

api/types/types.go

Lines changed: 242 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,242 @@
1+
/*
2+
Licensed under the Apache License, Version 2.0 (the "License");
3+
you may not use this file except in compliance with the License.
4+
You may obtain a copy of the License at
5+
6+
http://www.apache.org/licenses/LICENSE-2.0
7+
8+
Unless required by applicable law or agreed to in writing, software
9+
distributed under the License is distributed on an "AS IS" BASIS,
10+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
See the License for the specific language governing permissions and
12+
limitations under the License.
13+
*/
14+
15+
package types
16+
17+
import (
18+
"github.com/docker/go-connections/nat"
19+
)
20+
21+
const (
22+
DefaultVanName string = "skupper"
23+
HostPath string = "/tmp/skupper"
24+
CertPath = HostPath + "/qpid-dispatch-certs/"
25+
ConnPath = HostPath + "/connections/"
26+
ConsoleUsersPath = HostPath + "/console-users/"
27+
SaslConfigPath = HostPath + "/sasl-config/"
28+
ServicePath = HostPath + "/services/"
29+
)
30+
31+
// TransportMode describes how a qdr is intended to be deployed, either interior or edge
32+
type TransportMode string
33+
34+
const (
35+
// TransportModeInterior means the qdr will participate in inter-router protocol exchanges
36+
TransportModeInterior TransportMode = "interior"
37+
// TransportModeEdge means that the qdr will connect to interior routers for network access
38+
TransportModeEdge = "edge"
39+
)
40+
41+
// Transport constants
42+
const (
43+
TransportDeploymentName string = "skupper-router"
44+
TransportComponentName string = "router"
45+
DefaultTransportImage string = "quay.io/interconnectedcloud/qdrouterd"
46+
TransportContainerName string = "router"
47+
TransportLivenessPort int32 = 9090
48+
TransportEnvConfig string = "QDROUTERD_CONF"
49+
TransportSaslConfig string = "skupper-sasl-config"
50+
TransportNetworkName string = "skupper-network"
51+
)
52+
53+
var TransportPrometheusAnnotations = map[string]string{
54+
"prometheus.io/port": "9090",
55+
"prometheus.io/scrape": "true",
56+
}
57+
58+
// Controller constants
59+
const (
60+
ControllerDeploymentName string = "skupper-proxy-controller"
61+
ControllerComponentName string = "controller"
62+
DefaultControllerImage string = "quay.io/skupper/skupper-docker-controller"
63+
ControllerContainerName string = "proxy-controller"
64+
DefaultProxyImage string = "quay.io/skupper/proxy-simple"
65+
ControllerConfigPath string = "/etc/messaging/"
66+
)
67+
68+
// Console constants
69+
const (
70+
ConsolePortName string = "console"
71+
ConsoleServiceName string = "skupper-console"
72+
ConsoleDefaultServicePort int32 = 8080
73+
ConsoleDefaultServiceTargetPort int32 = 8080
74+
ConsoleOpenShiftServicePort int32 = 8888
75+
ConsoleOpenShiftOauthServicePort int32 = 443
76+
ConsoleOpenShiftOuathServiceTargetPort int32 = 8443
77+
ConsoleOpenShiftServingCerts string = "skupper-proxy-certs"
78+
)
79+
80+
type ConsoleAuthMode string
81+
82+
const (
83+
ConsoleAuthModeInternal ConsoleAuthMode = "internal"
84+
ConsoleAuthModeUnsecured = "unsecured"
85+
)
86+
87+
// Assembly constants
88+
const (
89+
EdgeRole string = "edge"
90+
EdgeRouteName string = "skupper-edge"
91+
EdgeListenerPort int32 = 45671
92+
InterRouterRole string = "inter-router"
93+
InterRouterListenerPort int32 = 55671
94+
InterRouterRouteName string = "skupper-inter-router"
95+
InterRouterProfile string = "skupper-internal"
96+
)
97+
98+
// Controller Service Interface constants
99+
const (
100+
ServiceSyncAddress = "mc/$skupper-service-sync"
101+
LocalServiceDefsFile = ServicePath + "/local/skupper-services"
102+
AllServiceDefsFile = ServicePath + "/all/skupper-services"
103+
)
104+
105+
// TODO: what is possiblity of using types from skupper itself (e.g. no namespace for docker
106+
// or we change the name to endpoint, etc.
107+
// VanRouterSpec is the specification of VAN network with router, controller and assembly
108+
type VanRouterSpec struct {
109+
Name string `json:"name,omitempty"`
110+
// Namespace string `json:"namespace,omitempty"`
111+
AuthMode ConsoleAuthMode `json:"authMode,omitempty"`
112+
Transport DeploymentSpec `json:"transport,omitempty"`
113+
Controller DeploymentSpec `json:"controller,omitempty"`
114+
Assembly AssemblySpec `json:"assembly,omitempty"`
115+
Users []User `json:"users,omitempty"`
116+
CertAuthoritys []CertAuthority `json:"certAuthoritys,omitempty"`
117+
Credentials []Credential `json:"credentials,omitempty"`
118+
}
119+
120+
// DeploymentSpec for the VAN router or controller components to run within a cluster
121+
type DeploymentSpec struct {
122+
Image string `json:"image,omitempty"`
123+
LivenessPort int32 `json:"livenessPort,omitempty"`
124+
Labels map[string]string `json:"labels,omitempty"`
125+
// Annotations map[string]string `json:"annotations,omitempty"`
126+
EnvVar []string `json:"envVar,omitempty"`
127+
Ports nat.PortSet `json:"ports,omitempty"`
128+
Volumes []string `json:"volumes,omitempty"`
129+
Mounts map[string]string `json:"mounts,omitempty"`
130+
}
131+
132+
// AssemblySpec for the links and connectors that form the VAN topology
133+
type AssemblySpec struct {
134+
Name string `json:"name,omitempty"`
135+
Mode string `json:"mode,omitempty"`
136+
Listeners []Listener `json:"listeners,omitempty"`
137+
InterRouterListeners []Listener `json:"interRouterListeners,omitempty"`
138+
EdgeListeners []Listener `json:"edgeListeners,omitempty"`
139+
SslProfiles []SslProfile `json:"sslProfiles,omitempty"`
140+
Connectors []Connector `json:"connectors,omitempty"`
141+
InterRouterConnectors []Connector `json:"interRouterConnectors,omitempty"`
142+
EdgeConnectors []Connector `json:"edgeConnectors,omitempty"`
143+
}
144+
145+
type Listener struct {
146+
Name string `json:"name,omitempty"`
147+
Host string `json:"host,omitempty"`
148+
Port int32 `json:"port"`
149+
RouteContainer bool `json:"routeContainer,omitempty"`
150+
Http bool `json:"http,omitempty"`
151+
Cost int32 `json:"cost,omitempty"`
152+
SslProfile string `json:"sslProfile,omitempty"`
153+
SaslMechanisms string `json:"saslMechanisms,omitempty"`
154+
AuthenticatePeer bool `json:"authenticatePeer,omitempty"`
155+
LinkCapacity int32 `json:"linkCapacity,omitempty"`
156+
}
157+
158+
type SslProfile struct {
159+
Name string `json:"name,omitempty"`
160+
Cert string `json:"cert,omitempty"`
161+
Key string `json:"key,omitempty"`
162+
CaCert string `json:"caCert,omitempty"`
163+
}
164+
165+
type ConnectorRole string
166+
167+
const (
168+
ConnectorRoleInterRouter ConnectorRole = "inter-router"
169+
ConnectorRoleEdge = "edge"
170+
)
171+
172+
type Connector struct {
173+
Name string `json:"name,omitempty"`
174+
Role string `json:"role,omitempty"`
175+
Host string `json:"host"`
176+
Port string `json:"port"`
177+
RouteContainer bool `json:"routeContainer,omitempty"`
178+
Cost int32 `json:"cost,omitempty"`
179+
VerifyHostname bool `json:"verifyHostname,omitempty"`
180+
SslProfile string `json:"sslProfile,omitempty"`
181+
LinkCapacity int32 `json:"linkCapacity,omitempty"`
182+
}
183+
184+
type Credential struct {
185+
CA string
186+
Name string
187+
Subject string
188+
Hosts string
189+
ConnectJson bool
190+
Post bool
191+
}
192+
193+
type CertAuthority struct {
194+
Name string
195+
}
196+
197+
type User struct {
198+
Name string
199+
Password string
200+
}
201+
202+
type TransportConnectedSites struct {
203+
Direct int
204+
Indirect int
205+
Total int
206+
}
207+
208+
type ServiceInterface struct {
209+
Address string `json:"address"`
210+
Protocol string `json:"protocol"`
211+
Port int `json:"port"`
212+
Headless *Headless `json:"headless,omitempty"`
213+
Targets []ServiceInterfaceTarget `json:"targets"`
214+
Origin string `json:"origin,omitempty"`
215+
Alias string `json:"alias,omitempty"`
216+
}
217+
218+
type ServiceInterfaceTarget struct {
219+
Name string `json:"name,omitempty"`
220+
Selector string `json:"selector"`
221+
TargetPort int `json:"targetPort,omitempty"`
222+
}
223+
224+
type Headless struct {
225+
Name string `json:"name"`
226+
Size int `json:"size"`
227+
TargetPort int `json:"targetPort,omitempty"`
228+
}
229+
230+
type ByServiceInterfaceAddress []ServiceInterface
231+
232+
func (a ByServiceInterfaceAddress) Len() int {
233+
return len(a)
234+
}
235+
236+
func (a ByServiceInterfaceAddress) Less(i, j int) bool {
237+
return a[i].Address > a[i].Address
238+
}
239+
240+
func (a ByServiceInterfaceAddress) Swap(i, j int) {
241+
a[i], a[j] = a[j], a[i]
242+
}

client/client.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package client
2+
3+
import (
4+
"time"
5+
6+
"github.com/skupperproject/skupper-docker/pkg/docker/libdocker"
7+
)
8+
9+
// A VAN client manages orchestration and communication with the network components
10+
type VanClient struct {
11+
DockerInterface libdocker.Interface
12+
}
13+
14+
func NewClient(endpoint string) (*VanClient, error) {
15+
c := &VanClient{}
16+
17+
c.DockerInterface = libdocker.ConnectToDockerOrDie(endpoint, 0, 10*time.Second)
18+
19+
return c, nil
20+
}

0 commit comments

Comments
 (0)