Skip to content
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

Implement karmadactl get to support pull mode cluster #1575

Merged
merged 1 commit into from
Apr 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions artifacts/agent/karmada-agent.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ spec:
- --karmada-kubeconfig=/etc/kubeconfig/karmada-kubeconfig
- --karmada-context={{karmada_context}}
- --cluster-name={{member_cluster_name}}
- --cluster-api-endpoint={{member_cluster_api_endpoint}}
- --cluster-status-update-frequency=10s
- --v=4
volumeMounts:
Expand Down
5 changes: 5 additions & 0 deletions hack/deploy-karmada-agent.sh
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,17 @@ kubectl apply -f "${REPO_ROOT}/artifacts/agent/clusterrolebinding.yaml"
# create secret
kubectl create secret generic karmada-kubeconfig --from-file=karmada-kubeconfig="${KARMADA_APISERVER_KUBECONFIG}" -n "${KARMADA_SYSTEM_NAMESPACE}"

# extract api endpoint of member cluster
MEMBER_CLUSTER=$(kubectl config view -o jsonpath='{.contexts[?(@.name == "'${MEMBER_CLUSTER_NAME}'")].context.cluster}')
MEMBER_CLUSTER_API_ENDPOINT=$(kubectl config view -o jsonpath='{.clusters[?(@.name == "'${MEMBER_CLUSTER}'")].cluster.server}')

# deploy karmada agent
TEMP_PATH=$(mktemp -d)
cp "${REPO_ROOT}"/artifacts/agent/karmada-agent.yaml "${TEMP_PATH}"/karmada-agent.yaml
sed -i'' -e "s/{{karmada_context}}/${KARMADA_APISERVER_CONTEXT_NAME}/g" "${TEMP_PATH}"/karmada-agent.yaml
sed -i'' -e "s/{{member_cluster_name}}/${MEMBER_CLUSTER_NAME}/g" "${TEMP_PATH}"/karmada-agent.yaml
sed -i'' -e "s/{{image_pull_policy}}/${AGENT_IMAGE_PULL_POLICY}/g" "${TEMP_PATH}"/karmada-agent.yaml
sed -i'' -e "s|{{member_cluster_api_endpoint}}|${MEMBER_CLUSTER_API_ENDPOINT}|g" "${TEMP_PATH}"/karmada-agent.yaml
echo -e "Apply dynamic rendered deployment in ${TEMP_PATH}/karmada-agent.yaml.\n"
kubectl apply -f "${TEMP_PATH}"/karmada-agent.yaml

Expand Down
13 changes: 1 addition & 12 deletions pkg/karmadactl/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ var (
{Name: "ADOPTION", Type: "string", Format: "", Priority: 0},
}

noPushModeMessage = "The karmadactl get command now only supports Push mode, [ %s ] are not push mode\n"
getShort = `Display one or many resources`
getShort = `Display one or many resources`
)

// NewCmdGet New get command
Expand Down Expand Up @@ -225,23 +224,13 @@ func (g *CommandGetOptions) Run(karmadaConfig KarmadaConfig, cmd *cobra.Command,
return err
}

var noPushModeCluster []string
wg.Add(len(g.Clusters))
for idx := range g.Clusters {
if clusterInfos[g.Clusters[idx]].ClusterSyncMode != clusterv1alpha1.Push {
noPushModeCluster = append(noPushModeCluster, g.Clusters[idx])
wg.Done()
continue
}

g.setClusterProxyInfo(karmadaRestConfig, g.Clusters[idx], clusterInfos)
f := getFactory(g.Clusters[idx], clusterInfos)
go g.getObjInfo(&wg, &mux, f, g.Clusters[idx], &objs, &allErrs, args)
}
wg.Wait()
if len(noPushModeCluster) != 0 {
fmt.Println(fmt.Sprintf(noPushModeMessage, strings.Join(noPushModeCluster, ",")))
}

// sort objects by resource kind to classify them
sort.Slice(objs, func(i, j int) bool {
Expand Down