Skip to content

Commit

Permalink
Feat:Add Gateway Plugin Support (#686)
Browse files Browse the repository at this point in the history
* Install the Gateway plugin in fleet

Signed-off-by: Gidi233 <[email protected]>

* Support the Gateway plugin in application

Signed-off-by: Gidi233 <[email protected]>

* Add example

Signed-off-by: Gidi233 <[email protected]>

* Add gen

Signed-off-by: Gidi233 <[email protected]>

* fix warning and add log

Signed-off-by: Gidi233 <[email protected]>

* Change comments and redundant logic

Signed-off-by: Gidi233 <[email protected]>

* Change example

Signed-off-by: Gidi233 <[email protected]>

* add gen

Signed-off-by: Gidi233 <[email protected]>

* fix

Signed-off-by: Gidi233 <[email protected]>

* fix example

Signed-off-by: Gidi233 <[email protected]>

---------

Signed-off-by: Gidi233 <[email protected]>
  • Loading branch information
Gidi233 authored Sep 18, 2024
1 parent bfd6a70 commit edd2ba6
Show file tree
Hide file tree
Showing 23 changed files with 1,090 additions and 69 deletions.
56 changes: 53 additions & 3 deletions docs/content/en/references/apps_v1alpha1_types.html
Original file line number Diff line number Diff line change
Expand Up @@ -1707,13 +1707,12 @@ <h3 id="apps.kurator.dev/v1alpha1.RolloutConfig">RolloutConfig
<td>
<code>trafficRoutingProvider</code><br>
<em>
string
Kurator fleet/v1alpha1.Provider
</em>
</td>
<td>
<em>(Optional)</em>
<p>TrafficRoutingProvider defines traffic routing provider.
Kurator only supports istio for now.
Kurator supports istio,kuma,nginx for now.
Other provider will be added later.</p>
</td>
</tr>
Expand Down Expand Up @@ -2213,6 +2212,57 @@ <h3 id="apps.kurator.dev/v1alpha1.TrafficRoutingConfig">TrafficRoutingConfig
</tr>
<tr>
<td>
<code>host</code><br>
<em>
string
</em>
</td>
<td>
<em>(Optional)</em>
<p>Host defines the domain name you specify.
Only for NGINX
Fill in the host field with your own domain as the host of the Ingress.
The actual created Ingress is as follows:</p>
<pre><code class="language-yaml">apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: nginx
namespace: application.syncPolicies.rollout.workload.namespace
labels:
app: application.syncPolicies.rollout.ServiceName
annotations:
kubernetes.io/ingress.class: &quot;nginx&quot;
spec:
rules:
- host: &quot;&quot;
http:
paths:
- pathType: Prefix
path: &quot;/&quot;
backend:
service:
name: application.syncPolicies.rollout.ServiceName
port:
number: application.syncPolicies.rollout.port
</code></pre>
</td>
</tr>
<tr>
<td>
<code>protocol</code><br>
<em>
string
</em>
</td>
<td>
<em>(Optional)</em>
<p>Protocol defines the protocol used by Kuma
Only for kuma
Defaults to http</p>
</td>
</tr>
<tr>
<td>
<code>canaryStrategy</code><br>
<em>
<a href="#apps.kurator.dev/v1alpha1.CanaryConfig">
Expand Down
80 changes: 79 additions & 1 deletion docs/content/en/references/fleet_v1alpha1_types.html
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ <h3 id="fleet.kurator.dev/v1alpha1.ChartConfig">ChartConfig
<p>
(<em>Appears on:</em>
<a href="#fleet.kurator.dev/v1alpha1.BackupConfig">BackupConfig</a>,
<a href="#fleet.kurator.dev/v1alpha1.Config">Config</a>,
<a href="#fleet.kurator.dev/v1alpha1.DistributedStorageConfig">DistributedStorageConfig</a>,
<a href="#fleet.kurator.dev/v1alpha1.FlaggerConfig">FlaggerConfig</a>,
<a href="#fleet.kurator.dev/v1alpha1.GrafanaConfig">GrafanaConfig</a>,
Expand Down Expand Up @@ -399,6 +400,65 @@ <h3 id="fleet.kurator.dev/v1alpha1.ChartConfig">ChartConfig
</table>
</div>
</div>
<h3 id="fleet.kurator.dev/v1alpha1.Config">Config
</h3>
<p>
(<em>Appears on:</em>
<a href="#fleet.kurator.dev/v1alpha1.FlaggerConfig">FlaggerConfig</a>)
</p>
<div class="md-typeset__scrollwrap">
<div class="md-typeset__table td-content">
<table>
<thead>
<tr>
<th>Field</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<code>chart</code><br>
<em>
<a href="#fleet.kurator.dev/v1alpha1.ChartConfig">
ChartConfig
</a>
</em>
</td>
<td>
<em>(Optional)</em>
<p>Chart defines the helm chart config of the TrafficRoutingProvider.
For Example, using the following configuration to change the version of nginx installed.</p>
<pre><code class="language-yaml">repo: https://kubernetes.github.io/ingress-nginx
version: 4.10.0
</code></pre>
</td>
</tr>
<tr>
<td>
<code>extraArgs</code><br>
<em>
<a href="https://pkg.go.dev/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1?tab=doc#JSON">
Kubernetes /apiextensions/v1.JSON
</a>
</em>
</td>
<td>
<em>(Optional)</em>
<p>ExtraArgs is the set of extra arguments for TrafficRoutingProvider&rsquo;s chart.
You can pass in values according to your needs.
For Example, using the following configuration to change the port that Prometheus uses to scrape metrics.</p>
<pre><code class="language-yaml">values:
controller:
podAnnotations:
prometheus.io/port: 10378
</code></pre>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<h3 id="fleet.kurator.dev/v1alpha1.Device">Device
</h3>
<p>
Expand Down Expand Up @@ -665,10 +725,11 @@ <h3 id="fleet.kurator.dev/v1alpha1.FlaggerConfig">FlaggerConfig
</em>
</td>
<td>
<em>(Optional)</em>
<p>TrafficRoutingProvider defines traffic routing provider.
And Kurator will install flagger in trafficRoutingProvider&rsquo;s namespace
For example, If you use <code>istio</code> as a provider, flager will be installed in istio&rsquo;s namespace <code>istio-system</code>.
And if you use <code>istio</code> as a provider, you need to install it manually.
Otherwise, you can configure it in ProviderConfig (or use the default configuration) and Kurator will automatically deploy it.
Other provider will be added later.</p>
</td>
</tr>
Expand All @@ -685,6 +746,23 @@ <h3 id="fleet.kurator.dev/v1alpha1.FlaggerConfig">FlaggerConfig
you can also specify a private testloader in the Application.Spec.SyncPolicies.Rollout.TestLoader</p>
</td>
</tr>
<tr>
<td>
<code>config</code><br>
<em>
<a href="#fleet.kurator.dev/v1alpha1.Config">
Config
</a>
</em>
</td>
<td>
<em>(Optional)</em>
<p>ProviderConfig defines the helm configuration for the TrafficRoutingProvider.
You can pass in a custom helm configuration to install the TrafficRoutingProvider
And default value is in <code>./pkg/fleet-manager/manifests/plugins/</code>
Currently only used for Kuma and Nginx</p>
</td>
</tr>
</tbody>
</table>
</div>
Expand Down
21 changes: 12 additions & 9 deletions docs/proposals/rollout/Add_Gateway_Plugin_Support.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,31 +42,34 @@ We will delve into the API design required to support these configurations. The
type TrafficRoutingConfig struct {
...
// for NGINX
// The default created ingress is as follows, (replace app.example.com with your own domain, and change the path matching rules as needed)
// The default created ingress is as follows, (Fill in `host` with your own domain)
// ```yaml
// apiVersion: networking.k8s.io/v1
// kind: Ingress
// metadata:
// name: application.syncPolicies.rollout.name
// namespace: application.syncPolicies.rollout.namespace
// name: nginx
// namespace: application.syncPolicies.rollout.workload.namespace
// labels:
// app: application.syncPolicies.rollout.name
// app: application.syncPolicies.rollout.ServiceName
// annotations:
// kubernetes.io/ingress.class: "nginx"
// spec:
// rules:
// - host: "app.example.com"
// - host: ""
// http:
// paths:
// - pathType: Prefix
// path: "/"
// backend:
// service:
// name: application.syncPolicies.rollout.name
// name: application.syncPolicies.rollout.ServiceName
// port:
// number: 80
// number: application.syncPolicies.rollout.port
// ```
// +optional
Ingress *ingressv1.IngressRule `json:"ingress,omitempty"`
// for Kuma
Host string `json:"host,omitempty"`

// for kuma
// Defaults to http
// +optional
Protocol string `json:"protocol,omitempty"`
Expand Down
82 changes: 82 additions & 0 deletions examples/rollout/ab-testingNginx.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
apiVersion: apps.kurator.dev/v1alpha1
kind: Application
metadata:
name: abtesting-nginx-demo
namespace: default
spec:
source:
gitRepository:
interval: 3m0s
ref:
branch: master
timeout: 1m0s
url: https://github.com/stefanprodan/podinfo
syncPolicies:
- destination:
fleet: quickstart
kustomization:
interval: 0s
path: ./deploy/webapp
prune: true
timeout: 2m0s
rollout:
testLoader: true
trafficRoutingProvider: nginx
workload:
apiVersion: apps/v1
name: backend
kind: Deployment
namespace: webapp
serviceName: backend
port: 9898
rolloutPolicy:
trafficRouting:
analysisTimes: 3
timeoutSeconds: 60
host: "app.example.com"
match:
- headers:
x-canary:
exact: "insider"
- headers:
cookie:
exact: "canary"
trafficAnalysis:
checkIntervalSeconds: 90
checkFailedTimes: 2
metrics:
- name: nginx-request-success-rate
intervalSeconds: 90
thresholdRange:
min: 99
customMetric:
provider:
type: prometheus
address: http://ingress-nginx-flagger-kurator-member-prometheus.ingress-nginx:9090
query: |
sum(
rate(
http_requests_total{
status!~"5.*"
}[{{ interval }}]
)
)
/
sum(
rate(
http_requests_total[{{ interval }}]
)
) * 100
webhooks:
timeoutSeconds: 60
command:
- "hey -z 1m -q 10 -c 2 http://app.example.com/"
rolloutTimeoutSeconds: 600
- destination:
fleet: quickstart
kustomization:
targetNamespace: default
interval: 5m0s
path: ./kustomize
prune: true
timeout: 2m0s
75 changes: 75 additions & 0 deletions examples/rollout/blue_greenNginx.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
apiVersion: apps.kurator.dev/v1alpha1
kind: Application
metadata:
name: blue-green-nginx-demo
namespace: default
spec:
source:
gitRepository:
interval: 3m0s
ref:
branch: master
timeout: 1m0s
url: https://github.com/stefanprodan/podinfo
syncPolicies:
- destination:
fleet: quickstart
kustomization:
interval: 0s
path: ./deploy/webapp
prune: true
timeout: 2m0s
rollout:
testLoader: true
trafficRoutingProvider: nginx
workload:
apiVersion: apps/v1
name: backend
kind: Deployment
namespace: webapp
serviceName: backend
port: 9898
rolloutPolicy:
trafficRouting:
analysisTimes: 3
timeoutSeconds: 60
host: "app.example.com"
trafficAnalysis:
checkIntervalSeconds: 90
checkFailedTimes: 2
metrics:
- name: nginx-request-success-rate
intervalSeconds: 90
thresholdRange:
min: 99
customMetric:
provider:
type: prometheus
address: http://ingress-nginx-flagger-kurator-member-prometheus.ingress-nginx:9090
query: |
sum(
rate(
http_requests_total{
status!~"5.*"
}[{{ interval }}]
)
)
/
sum(
rate(
http_requests_total[{{ interval }}]
)
) * 100
webhooks:
timeoutSeconds: 60
command:
- "hey -z 1m -q 10 -c 2 http://app.example.com/"
rolloutTimeoutSeconds: 600
- destination:
fleet: quickstart
kustomization:
targetNamespace: default
interval: 5m0s
path: ./kustomize
prune: true
timeout: 2m0s
Loading

0 comments on commit edd2ba6

Please sign in to comment.