-
Notifications
You must be signed in to change notification settings - Fork 858
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat: Support trait with custom resource be dispatched to hubcluster #3774
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3774 +/- ##
==========================================
+ Coverage 63.87% 63.90% +0.02%
==========================================
Files 309 309
Lines 29439 29452 +13
==========================================
+ Hits 18805 18822 +17
+ Misses 8196 8191 -5
- Partials 2438 2439 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
2b6dd75
to
f705692
Compare
d46f4e6
to
ed40fd4
Compare
Signed-off-by: fourierr <maxiangboo@qq.com>
ed40fd4
to
495aced
Compare
The following is an example of how to use controlPlaneOnly.
hubcpuscaler: {
type: "trait"
annotations: {}
labels: {
"ui-hidden": "true"
}
description: "Automatically scale the component based on CPU usage."
attributes: {
appliesToWorkloads: ["deployments.apps"]
controlPlaneOnly: true
}
}
template: {
outputs: hubcpuscaler: {
apiVersion: "autoscaling/v1"
kind: "HorizontalPodAutoscaler"
metadata: name: context.name
spec: {
scaleTargetRef: {
apiVersion: parameter.targetAPIVersion
kind: parameter.targetKind
name: context.name
}
minReplicas: parameter.min
maxReplicas: parameter.max
targetCPUUtilizationPercentage: parameter.cpuUtil
}
}
parameter: {
// +usage=Specify the minimal number of replicas to which the autoscaler can scale down
min: *1 | int
// +usage=Specify the maximum number of of replicas to which the autoscaler can scale up
max: *10 | int
// +usage=Specify the average CPU utilization, for example, 50 means the CPU usage is 50%
cpuUtil: *50 | int
// +usage=Specify the apiVersion of scale target
targetAPIVersion: *"apps/v1" | string
// +usage=Specify the kind of scale target
targetKind: *"Deployment" | string
}
}
apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
name: fourierapp03
namespace: fourier
spec:
components:
- name: fourierapp03-fouriercomponent-01
type: webservice
properties:
image: busybox:latest
imagePullPolicy: IfNotPresent
cmd: [ "sleep", "10000" ]
cpu: "0.1"
mem: "100Mi"
traits:
- type: hubcpuscaler
properties:
min: 1
max: 10
cpuPercent: 60
- type: expose
properties:
port: [ 80 ]
policies:
- name: fourierapp03-topology-01
type: topology
properties:
clusters: [ "kind01" ]
namespace: fourier01
- name: fourierapp03-topology-02
type: topology
properties:
clusters: [ "kind02" ]
namespace: fourier02
workflow:
steps:
- type: deploy
name: fourierapp03-deploy-01
properties:
policies: [ "fourierapp03-topology-01","fourierapp03-topology-02" ]
apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
name: fourierapp03
namespace: fourier
spec:
components:
- name: fourierapp03-fouriercomponent-01
type: webservice
properties:
image: busybox:latest
imagePullPolicy: IfNotPresent
cmd: [ "sleep", "10000" ]
cpu: "0.1"
mem: "100Mi"
traits:
- type: expose
properties:
port: [ 80 ]
policies:
- name: fourierapp03-topology-01
type: topology
properties:
clusters: [ "kind01" ]
namespace: fourier01
- name: fourierapp03-topology-02
type: topology
properties:
clusters: [ "kind02" ]
namespace: fourier02
workflow:
steps:
- type: deploy
name: fourierapp03-deploy-01
properties:
policies: [ "fourierapp03-topology-01","fourierapp03-topology-02" ] |
Signed-off-by: Xiangbo Ma maxiangboo@cmbchina.com
Description of your changes
Support trait with custom resource be dispatched to hubcluster
Fixes #3754
The following is an example of how to use controlPlaneOnly
hubcpuscaler
is defined on the basis ofcpusccaler
, so that HPA can be deployed tohubcuster
local
, deployment and service were dispatched to the clusterkind01
,kind02
.hubcpuscaler
in application, the Custom Resource inlocal
will be GC Simultaneously. as shown belowI have:
make reviewable
to ensure this PR is ready for review.backport release-x.y
labels to auto-backport this PR if necessary.