Feature: Porting workloads from legacy clusters #1039
Replies: 8 comments 43 replies
-
One possible solution: Maybe, we need a tool to help users convert single-cluster applications to mutil-cluster applications. |
Beta Was this translation helpful? Give feedback.
-
IMHO, for the first stage, we can achieve the basic features:
for the second stage, it should be more automatically and intelligently:
|
Beta Was this translation helpful? Give feedback.
-
For the following scenario, can we take over the existing workloads directly? eg: I have three clusters A, B and C, there is a deployment named nginx on both A and C. Now A, B and C are all managed by karmada, I created a deployment named nginx in karmada apiserver, I hope to distribute it to clusters A and B, the existing nginx deployment in cluster A will be taken over by karmada (we will update it and add some labels to it), but nginx on cluster C will not be managed. |
Beta Was this translation helpful? Give feedback.
-
We have realized karmadactl migrate[root@master67 karmada]# karmadactl migrate -h
Migrate resources from legacy clusters to karmada control plane.
Usage:
karmadactl migrate <RESOURCE_TYPE> <RESOURCE_NAME> -n <NAME_SPACE> -c <CLUSTER_NAME> [flags]
Examples:
# Migrating deployment(default/nginx) from cluster1 to karmada.
karmadactl migrate deployment nginx -n default -c cluster1
# Only printing the converted resource, not to create them in karmada.
karmadactl migrate deployment nginx -n default -c cluster1 -o yaml|json
# Migrating deployment((default/nginx) with gvk from cluster1 to karmada.
karmadactl migrate deployment.v1.apps nginx -n default -c cluster1
# Migrating secret(default/default-token) from cluster1 to karmada.
karmadactl migrate secret default-token -n default -c cluster1
# If it's cluster of pull mode, you can use --cluster-kubeconfig and --cluster-context
karmadactl migrate deployment nginx -n default -c cluster1 --cluster-kubeconfig=<CLUSTER_KUBECONFIG_PATH> --cluster-context=<CLUSTER_CONTEXT>
Flags:
-c, --cluster string the name of legacy cluster (eg -c=member1)
--cluster-context string Context name of legacy cluster in kubeconfig. Only works when there are multiple contexts in the kubeconfig.
--cluster-kubeconfig string Path of the legacy cluster's kubeconfig.
--cluster-namespace string Namespace in the control plane where member cluster are stored. (default "karmada-cluster")
--dry-run Run the command in dry-run mode, without making any server requests.
-h, --help help for migrate
--karmada-context string Name of the cluster context in control plane kubeconfig file.
-n, --namespace string -n=namespace or -n namespace (default "default")
-o, --output string Output format. One of: json|yaml --output[root@master67 karmada]# karmadactl migrate deployment nginx -c=bj-47 -o yaml
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
deployment.kubernetes.io/revision: "1"
kubectl.kubernetes.io/last-applied-configuration: |
{"apiVersion":"apps/v1","kind":"Deployment","metadata":{"annotations":{},"labels":{"app":"nginx"},"name":"nginx","namespace":"default"},"spec":{"replicas":1,"selector":{"matchLabels":{"app":"nginx"}},"template":{"metadata":{"labels":{"app":"nginx"}},"spec":{"containers":[{"image":"nginx","name":"nginx"}]}}}}
creationTimestamp: "2021-12-06T16:32:57Z"
generation: 1
labels:
app: nginx
name: nginx
namespace: default
uid: 0bdb00b5-c162-464a-9845-831293aa4164
spec:
progressDeadlineSeconds: 600
replicas: 1
revisionHistoryLimit: 10
selector:
matchLabels:
app: nginx
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
creationTimestamp: null
labels:
app: nginx
spec:
containers:
- image: nginx
imagePullPolicy: Always
name: nginx
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds: 30
---
apiVersion: policy.karmada.io/v1alpha1
kind: PropagationPolicy
metadata:
creationTimestamp: null
name: nginx-propagation
namespace: default
spec:
placement:
clusterAffinity:
clusterNames:
- bj-47
resourceSelectors:
- apiVersion: apps/v1
kind: Deployment
name: nginx @dddddai and I collaborated on this code. https://github.com/lonelyCZ/karmada/blob/karmadactl-migrate/pkg/karmadactl/migrate.go Nextwe need to consider to import |
Beta Was this translation helpful? Give feedback.
-
Ah......IMHO, it's unnecessary to introduce a policy, if users don't wanna adopt the resource, they could update the propagation policy to control this(e.g. I believe the premise of problem is that the user's behavior is correct, otherwise it seems pointless |
Beta Was this translation helpful? Give feedback.
-
Proposing an annotation: const (
// ResourceConflictResolutionAnnotation is added to the resource template to specify how to resolve the conflict
// in case of resource already existing in member clusters.
// The valid value is:
// - overwrite: always overwrite the resource if already exist. The resource will be overwritten with the
// configuration from control plane.
// Note: Propagation of the resource template without this annotation will fail in case of already exists.
ResourceConflictResolutionAnnotation = "work.karmada.io/conflict-resolution"
) As discussed at the last community meeting, we are going to use a light-way annotation instead of extending current APIs to define the adoption behavior. @pigletfly How do you think? After that, we can back to this discussion and work out an |
Beta Was this translation helpful? Give feedback.
-
Ok, @iawia002 is interested in this feature #1039 (reply in thread), would you like to file this pr? |
Beta Was this translation helpful? Give feedback.
-
Perhaps, we can define a new command name. I think we can use Which name do you think is better? |
Beta Was this translation helpful? Give feedback.
-
Given a scenario that workloads already running in some clusters, how do we import these workloads to Karmada?
Beta Was this translation helpful? Give feedback.
All reactions