Skip to content

Commit 41e427d

Browse files
authored
Merge pull request #908 from kdorosh/add_gloo_upstreamRef
Gloo Upstream Ref for Upstream Config
2 parents 84ff6f7 + a286625 commit 41e427d

File tree

10 files changed

+503
-16
lines changed

10 files changed

+503
-16
lines changed

artifacts/flagger/crd.yaml

+15
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,21 @@ spec:
129129
- Ingress
130130
name:
131131
type: string
132+
upstreamRef:
133+
description: Gloo Upstream selector
134+
type: object
135+
required: [ "apiVersion", "kind", "name" ]
136+
properties:
137+
apiVersion:
138+
type: string
139+
kind:
140+
type: string
141+
enum:
142+
- Upstream
143+
name:
144+
type: string
145+
namespace:
146+
type: string
132147
service:
133148
description: Kubernetes Service spec
134149
type: object

charts/flagger/crds/crd.yaml

+15
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,21 @@ spec:
129129
- Ingress
130130
name:
131131
type: string
132+
upstreamRef:
133+
description: Gloo Upstream selector
134+
type: object
135+
required: [ "apiVersion", "kind", "name" ]
136+
properties:
137+
apiVersion:
138+
type: string
139+
kind:
140+
type: string
141+
enum:
142+
- Upstream
143+
name:
144+
type: string
145+
namespace:
146+
type: string
132147
service:
133148
description: Kubernetes Service spec
134149
type: object

docs/gitbook/tutorials/gloo-progressive-delivery.md

+11-3
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ and Flagger to automate canary releases and A/B testing.
1010
Flagger requires a Kubernetes cluster **v1.16** or newer and Gloo Edge ingress **1.6.0** or newer.
1111

1212
This guide was written for Flagger version **1.6.0** or higher. Prior versions of Flagger
13-
used Gloo upstream groups to handle canaries, but newer versions of Flagger use Gloo
14-
route tables to handle canaries as well as A/B testing.
13+
used Gloo `UpstreamGroup`s to handle canaries, but newer versions of Flagger use Gloo
14+
`RouteTable`s to handle canaries as well as A/B testing.
1515

1616
Install Gloo with Helm v3:
1717

@@ -36,7 +36,7 @@ helm upgrade -i flagger flagger/flagger \
3636
## Bootstrap
3737

3838
Flagger takes a Kubernetes deployment and optionally a horizontal pod autoscaler (HPA),
39-
then creates a series of objects (Kubernetes deployments, ClusterIP services and Gloo route tables groups).
39+
then creates a series of objects (Kubernetes deployments, ClusterIP services, Gloo route tables and upstreams).
4040
These objects expose the application outside the cluster and drive the canary analysis and promotion.
4141

4242
Create a test namespace:
@@ -94,6 +94,14 @@ metadata:
9494
name: podinfo
9595
namespace: test
9696
spec:
97+
# upstreamRef (optional)
98+
# defines an upstream to copy the spec from when flagger generates new upstreams.
99+
# necessary to copy over TLS config, circuit breakers, etc. (anything nonstandard)
100+
# upstreamRef:
101+
# apiVersion: gloo.solo.io/v1
102+
# kind: Upstream
103+
# name: podinfo-upstream
104+
# namespace: gloo-system
97105
provider: gloo
98106
# deployment reference
99107
targetRef:

kustomize/base/flagger/crd.yaml

+15
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,21 @@ spec:
129129
- Ingress
130130
name:
131131
type: string
132+
upstreamRef:
133+
description: Gloo Upstream selector
134+
type: object
135+
required: [ "apiVersion", "kind", "name" ]
136+
properties:
137+
apiVersion:
138+
type: string
139+
kind:
140+
type: string
141+
enum:
142+
- Upstream
143+
name:
144+
type: string
145+
namespace:
146+
type: string
132147
service:
133148
description: Kubernetes Service spec
134149
type: object

pkg/apis/flagger/v1beta1/canary.go

+5
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@ type CanarySpec struct {
7777
// +optional
7878
IngressRef *CrossNamespaceObjectReference `json:"ingressRef,omitempty"`
7979

80+
// Reference to Gloo Upstream resource. Upstream config is copied from
81+
// the referenced upstream to the upstreams generated by flagger.
82+
// +optional
83+
UpstreamRef *CrossNamespaceObjectReference `json:"upstreamRef,omitempty"`
84+
8085
// Service defines how ClusterIP services, service mesh or ingress routing objects are generated
8186
Service CanaryService `json:"service"`
8287

pkg/apis/flagger/v1beta1/zz_generated.deepcopy.go

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/apis/gloo/gloo/v1/types.go

+88-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package v1
22

33
import (
4+
v1 "github.com/fluxcd/flagger/pkg/apis/gloo/gateway/v1"
45
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
56
)
67

@@ -16,7 +17,14 @@ type Upstream struct {
1617
}
1718

1819
type UpstreamSpec struct {
19-
Kube KubeUpstream `json:"kube,omitempty"`
20+
Kube *KubeUpstream `json:"kube,omitempty"`
21+
SslConfig *UpstreamSslConfig `json:"sslConfig,omitempty"`
22+
CircuitBreakers *CircuitBreakerConfig `json:"circuitBreakers,omitempty"`
23+
ConnectionConfig *ConnectionConfig `json:"connectionConfig,omitempty"`
24+
UseHttp2 bool `json:"useHttp2,omitempty"`
25+
InitialStreamWindowSize uint32 `json:"initialStreamWindowSize,omitempty"`
26+
InitialConnectionWindowSize uint32 `json:"initialConnectionWindowSize,omitempty"`
27+
HttpProxyHostname string `json:"httpProxyHostName,omitempty"`
2028
}
2129

2230
type KubeUpstream struct {
@@ -26,6 +34,85 @@ type KubeUpstream struct {
2634
Selector map[string]string `json:"selector,omitempty"`
2735
}
2836

37+
type UpstreamSslConfig struct {
38+
Sni string `json:"sni,omitempty"`
39+
VerifySubjectAltName []string `json:"verifySubjectAltName,omitempty"`
40+
Parameters *SslParameters `json:"parameters,omitempty"`
41+
AlpnProtocols []string `json:"alpnProtocols,omitempty"`
42+
43+
/** SSLSecrets -- only one of these should be set */
44+
*UpstreamSslConfig_Sds `json:"sds,omitempty"`
45+
SecretRef *v1.ResourceRef `json:"secretRef,omitempty"`
46+
*UpstreamSslConfig_SslFiles `json:"sslFiles,omitempty"`
47+
}
48+
49+
// SSLFiles reference paths to certificates which can be read by the proxy off of its local filesystem
50+
type UpstreamSslConfig_SslFiles struct {
51+
TlsCert string `json:"tlsCert,omitempty"`
52+
TlsKey string `json:"tlsKey,omitempty"`
53+
RootCa string `json:"rootCa,omitempty"`
54+
}
55+
56+
// Use secret discovery service.
57+
type UpstreamSslConfig_Sds struct {
58+
TargetUri string `json:"targetUri,omitempty"`
59+
CertificatesSecretName string `json:"certificatesSecretName,omitempty"`
60+
ValidationContextName string `json:"validationContextName,omitempty"`
61+
62+
/** SDSBuilder -- onle one of the following can be set */
63+
CallCredentials *CallCredentials `json:"callCredentials,omitempty"`
64+
ClusterName string `json:"clusterName,omitempty"`
65+
}
66+
67+
type CallCredentials struct {
68+
FileCredentialSource *CallCredentials_FileCredentialSource `json:"fileCredentialSource,omitempty"`
69+
}
70+
71+
type CallCredentials_FileCredentialSource struct {
72+
TokenFileName string `json:"tokenFileName,omitempty"`
73+
Header string `json:"header,omitempty"`
74+
}
75+
76+
type SslParameters struct {
77+
MinimumProtocolVersion int32 `json:"minimumProtocolVersion,omitempty"`
78+
MaximumProtocolVersion int32 `json:"maximumProtocolVersion,omitempty"`
79+
CipherSuites []string `json:"cipherSuites,omitempty"`
80+
EcdhCurves []string `json:"ecdhCurves,omitempty"`
81+
}
82+
83+
type CircuitBreakerConfig struct {
84+
MaxConnections uint32 `json:"maxConnections,omitempty"`
85+
MaxPendingRequests uint32 `json:"maxPendingRequests,omitempty"`
86+
MaxRequests uint32 `json:"maxRequests,omitempty"`
87+
MaxRetries uint32 `json:"maxRetries,omitempty"`
88+
}
89+
90+
type ConnectionConfig struct {
91+
MaxRequestsPerConnection uint32 `json:"maxRequestsPerConnection,omitempty"`
92+
ConnectTimeout *Duration `json:"connectTimeout,omitempty"`
93+
TcpKeepalive *ConnectionConfig_TcpKeepAlive `json:"tcpKeepalive,omitempty"`
94+
PerConnectionBufferLimitBytes uint32 `json:"perConnectionBufferLimitBytes,omitempty"`
95+
CommonHttpProtocolOptions *ConnectionConfig_HttpProtocolOptions `json:"commonHttpProtocolOptions,omitempty"`
96+
}
97+
98+
type ConnectionConfig_TcpKeepAlive struct {
99+
KeepaliveProbes uint32 `json:"keepaliveProbes,omitempty"`
100+
KeepaliveTime *Duration `json:"keepaliveTime,omitempty"`
101+
KeepaliveInterval *Duration `json:"keepaliveInterval,omitempty"`
102+
}
103+
104+
type ConnectionConfig_HttpProtocolOptions struct {
105+
IdleTimeout *Duration `json:"idleTimeout,omitempty"`
106+
MaxHeadersCount uint32 `json:"maxHeadersCount,omitempty"`
107+
MaxStreamDuration *Duration `json:"maxStreamDuration,omitempty"`
108+
HeadersWithUnderscoresAction uint32 `json:"headersWithUnderscoresAction,omitempty"`
109+
}
110+
111+
type Duration struct {
112+
Seconds int64 `json:"seconds,omitempty"`
113+
Nanos int32 `json:"nanos,omitempty"`
114+
}
115+
29116
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
30117

31118
// UpstreamList is a list of Upstream resources

0 commit comments

Comments
 (0)