-
Notifications
You must be signed in to change notification settings - Fork 875
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: vela adopt command #5197
Feat: vela adopt command #5197
Conversation
Signed-off-by: Somefive <yd219913@alibaba-inc.com>
Codecov ReportBase: 61.12% // Head: 61.07% // Decreases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## master #5197 +/- ##
==========================================
- Coverage 61.12% 61.07% -0.06%
==========================================
Files 305 305
Lines 45377 45445 +68
==========================================
+ Hits 27738 27754 +16
- Misses 14788 14826 +38
- Partials 2851 2865 +14
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
@Somefive Could you print an example Application YAML? |
Sure. Below is an example for kruise helm chart. apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
creationTimestamp: null
labels:
app.oam.dev/adopt: helm
name: kruise
namespace: default
spec:
components:
- name: kruise.crds
properties:
objects:
- apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: advancedcronjobs.apps.kruise.io
- apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: broadcastjobs.apps.kruise.io
- apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: nodepodprobes.apps.kruise.io
- apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: persistentpodstates.apps.kruise.io
- apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: imagepulljobs.apps.kruise.io
- apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: resourcedistributions.apps.kruise.io
- apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: uniteddeployments.apps.kruise.io
- apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: daemonsets.apps.kruise.io
- apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: statefulsets.apps.kruise.io
- apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: workloadspreads.apps.kruise.io
- apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: podunavailablebudgets.policy.kruise.io
- apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: clonesets.apps.kruise.io
- apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: nodeimages.apps.kruise.io
- apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: containerrecreaterequests.apps.kruise.io
- apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: podprobemarkers.apps.kruise.io
- apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: sidecarsets.apps.kruise.io
type: k8s-objects
- name: kruise.ns.kruise-system
properties:
objects:
- apiVersion: v1
kind: Namespace
metadata:
name: kruise-system
type: k8s-objects
- name: kruise.DaemonSet.kruise-daemon
properties:
objects:
- apiVersion: apps/v1
kind: DaemonSet
metadata:
name: kruise-daemon
namespace: kruise-system
spec:
minReadySeconds: 3
selector:
matchLabels:
control-plane: daemon
template:
metadata:
labels:
control-plane: daemon
spec:
containers:
- args:
- --logtostderr=true
- --v=4
- --addr=:10221
- --feature-gates=
- --socket-file=
command:
- /kruise-daemon
env:
- name: KUBE_CACHE_MUTATION_DETECTOR
value: "true"
- name: NODE_NAME
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: spec.nodeName
image: openkruise/kruise-manager:v1.3.0
imagePullPolicy: Always
livenessProbe:
failureThreshold: 3
httpGet:
path: /healthz
port: 10221
scheme: HTTP
initialDelaySeconds: 60
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 1
name: daemon
resources:
limits:
cpu: 50m
memory: 128Mi
requests:
cpu: "0"
memory: "0"
volumeMounts:
- mountPath: /hostvarrun
name: runtime-socket
readOnly: true
hostNetwork: true
serviceAccountName: kruise-daemon
terminationGracePeriodSeconds: 10
tolerations:
- operator: Exists
volumes:
- hostPath:
path: /var/run
type: ""
name: runtime-socket
updateStrategy:
rollingUpdate:
maxUnavailable: 10%
type: RollingUpdate
type: k8s-objects
- name: kruise.Deployment.kruise-controller-manager
properties:
objects:
- apiVersion: apps/v1
kind: Deployment
metadata:
name: kruise-controller-manager
namespace: kruise-system
spec:
minReadySeconds: 3
replicas: 2
selector:
matchLabels:
control-plane: controller-manager
strategy:
rollingUpdate:
maxSurge: 100%
maxUnavailable: 0
type: RollingUpdate
template:
metadata:
labels:
control-plane: controller-manager
spec:
affinity:
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- podAffinityTerm:
labelSelector:
matchExpressions:
- key: control-plane
operator: In
values:
- controller-manager
topologyKey: kubernetes.io/hostname
weight: 100
containers:
- args:
- --enable-leader-election
- --metrics-addr=:8080
- --health-probe-addr=:8000
- --logtostderr=true
- --leader-election-namespace=kruise-system
- --v=4
- --feature-gates=
- --sync-period=0
command:
- /manager
env:
- name: KUBE_CACHE_MUTATION_DETECTOR
value: "true"
- name: POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: WEBHOOK_PORT
value: "9876"
- name: WEBHOOK_CONFIGURATION_FAILURE_POLICY_PODS
value: Ignore
image: openkruise/kruise-manager:v1.3.0
imagePullPolicy: Always
name: manager
ports:
- containerPort: 9876
name: webhook-server
protocol: TCP
- containerPort: 8080
name: metrics
protocol: TCP
- containerPort: 8000
name: health
protocol: TCP
readinessProbe:
httpGet:
path: readyz
port: 8000
resources:
limits:
cpu: 200m
memory: 512Mi
requests:
cpu: 100m
memory: 256Mi
hostNetwork: false
serviceAccountName: kruise-manager
terminationGracePeriodSeconds: 10
type: k8s-objects
- name: kruise.Service.kruise-webhook-service
properties:
objects:
- apiVersion: v1
kind: Service
metadata:
name: kruise-webhook-service
namespace: kruise-system
spec:
ports:
- port: 443
targetPort: 9876
selector:
control-plane: controller-manager
type: k8s-objects
- name: kruise.config
properties:
objects:
- apiVersion: v1
kind: Secret
metadata:
name: kruise-webhook-certs
namespace: kruise-system
type: k8s-objects
- name: kruise.sa
properties:
objects:
- apiVersion: v1
kind: Secret
metadata:
name: kruise-webhook-certs
namespace: kruise-system
type: k8s-objects
- name: kruise.operator
properties:
objects:
- apiVersion: v1
kind: Secret
metadata:
name: kruise-webhook-certs
namespace: kruise-system
type: k8s-objects
policies:
- name: read-only
properties:
rules:
- selector:
componentNames:
- kruise.crds
- kruise.ns.kruise-system
- kruise.DaemonSet.kruise-daemon
- kruise.Deployment.kruise-controller-manager
- kruise.Service.kruise-webhook-service
- kruise.config
- kruise.sa
- kruise.operator
type: read-only |
7742b1f
to
773590e
Compare
references/cli/adopt.go
Outdated
|
||
The adopted application can be customized. You can provide a CUE template file to | ||
the command and make your own assemble rules for the adoption application. You can | ||
refer to https://github.com/kubevela/kubevela/blob/master/references/cli/adopt.cue to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should write a doc for the rules instead of just giving one example.
} | ||
cmd.Flags().StringVarP(&o.Type, "type", "t", o.Type, fmt.Sprintf("The type of adoption. Available values: [%s]", strings.Join(adoptTypes, ", "))) | ||
cmd.Flags().StringVarP(&o.Mode, "mode", "m", o.Mode, fmt.Sprintf("The mode of adoption. Available values: [%s]", strings.Join(adoptModes, ", "))) | ||
cmd.Flags().StringVarP(&o.AppName, "app-name", "", o.AppName, "The name of application for adoption. If empty for helm type adoption, it will inherit the helm chart's name.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why don't just use name
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because name
could be ambiguous, like resource name
/ helm chart name
/ app name
, ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This Implementation is elegant! 👍
Signed-off-by: Somefive <yd219913@alibaba-inc.com>
773590e
to
e086243
Compare
Signed-off-by: Somefive <yd219913@alibaba-inc.com>
e086243
to
2439eaa
Compare
* Feat: vela adopt Signed-off-by: Somefive <yd219913@alibaba-inc.com> * Feat: support adopt native resources Signed-off-by: Somefive <yd219913@alibaba-inc.com> * Test: add test for vela adopt Signed-off-by: Somefive <yd219913@alibaba-inc.com> Signed-off-by: Somefive <yd219913@alibaba-inc.com>
* Feat: vela adopt Signed-off-by: Somefive <yd219913@alibaba-inc.com> * Feat: support adopt native resources Signed-off-by: Somefive <yd219913@alibaba-inc.com> * Test: add test for vela adopt Signed-off-by: Somefive <yd219913@alibaba-inc.com> Signed-off-by: Somefive <yd219913@alibaba-inc.com>
Signed-off-by: Somefive yd219913@alibaba-inc.com
Description of your changes
Fixes #3552
Fixes #2823
Support
vela adopt
command for adopting resources into KubeVela application.I have:
make reviewable
to ensure this PR is ready for review.How has this code been tested
Special notes for your reviewer