Skip to content

Commit

Permalink
Update klusterlet crd (#290)
Browse files Browse the repository at this point in the history
* Update klusterlet crd

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

* Fix ci

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

Signed-off-by: zhujian <[email protected]>
  • Loading branch information
zhujian7 authored Nov 30, 2022
1 parent 3185bd5 commit b8fc958
Show file tree
Hide file tree
Showing 85 changed files with 3,587 additions and 2,616 deletions.
11 changes: 11 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,14 @@ clean-test:

include ./test/integration-test.mk
include ./test/e2e/e2e-test.mk

# Update vendor
.PHONY: vendor
vendor:
go mod tidy
go mod vendor

# Copy CRDs
.PHONY: copy-crd
copy-crd: vendor
bash -x build/copy-crds.sh
29 changes: 29 additions & 0 deletions build/copy-crds.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash
# Copyright Contributors to the Open Cluster Management project

KLUSTERLET_CRD_FILE="./vendor/open-cluster-management.io/api/operator/v1/0000_00_operator.open-cluster-management.io_klusterlets.crd.yaml"
CLUSTER_MANAGER_CRD_FILE="./vendor/open-cluster-management.io/api/operator/v1/0000_01_operator.open-cluster-management.io_clustermanagers.crd.yaml"

ALL_FILES=("./pkg/cmd/join/scenario/join/klusterlets.crd.yaml"
"./pkg/cmd/init/scenario/init/clustermanagers.crd.yaml"
)

cp "$KLUSTERLET_CRD_FILE" "${ALL_FILES[0]}"
cp "$CLUSTER_MANAGER_CRD_FILE" "${ALL_FILES[1]}"

COMMUNITY_COPY_HEADER_FILE="$PWD/build/copyright-header.txt"

if [ ! -f "$COMMUNITY_COPY_HEADER_FILE" ]; then
echo "File $COMMUNITY_COPY_HEADER_FILE not found!"
exit 1
fi
COMMUNITY_COPY_HEADER_STRING=$(cat "$COMMUNITY_COPY_HEADER_FILE")

for FILE in "${ALL_FILES[@]}"
do
if [ -f "$FILE" ] && ! grep -q "$COMMUNITY_COPY_HEADER_STRING" "$FILE"; then
echo "# $COMMUNITY_COPY_HEADER_STRING" > tempfile;
cat "$FILE" >> tempfile;
mv tempfile "$FILE";
fi
done
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ require (
k8s.io/klog/v2 v2.60.1
k8s.io/kubectl v0.24.3
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9
open-cluster-management.io/api v0.8.0
open-cluster-management.io/api v0.9.1-0.20221116150238-55691c2c5f04
open-cluster-management.io/cluster-proxy v0.1.2
open-cluster-management.io/managed-serviceaccount v0.2.1-0.20220427065210-de6a7b7b5be8
sigs.k8s.io/apiserver-network-proxy v0.0.30
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1672,8 +1672,8 @@ open-cluster-management.io/addon-framework v0.1.1-0.20211223101009-d6b1a7adae93/
open-cluster-management.io/addon-framework v0.2.1-0.20220317063747-100a0230a883/go.mod h1:8QG1fHwPCEdyRrzY2Jji+qhMmJl+/HzTpuSDVmeG+7s=
open-cluster-management.io/api v0.5.0/go.mod h1:9qiA5h/8kvPQnJEOlAPHVjRO9a1jCmDhGzvgMBvXEaE=
open-cluster-management.io/api v0.5.1-0.20220112073018-2d280a97a052/go.mod h1:0IUTh8J+p4pv1THh1r9oO0luX9Z1FLDEAmvzW09qC0o=
open-cluster-management.io/api v0.8.0 h1:hQLNyvvdx0G0iNxq80RWp93epNsUtsqJdLmGbXiYG5o=
open-cluster-management.io/api v0.8.0/go.mod h1:+OEARSAl2jIhuLItUcS30UgLA3khmA9ihygLVxzEn+U=
open-cluster-management.io/api v0.9.1-0.20221116150238-55691c2c5f04 h1:lXewKgs1MeWN1wPIlMGQxfQj83CgjkNXQKVJVYQEB5I=
open-cluster-management.io/api v0.9.1-0.20221116150238-55691c2c5f04/go.mod h1:9KkJPh/zpDevXj2P+zkvSVjC2pq2PQ1JDNLLEes8TEc=
open-cluster-management.io/cluster-proxy v0.1.2 h1:0WYhPEZT6Wlt0dyE35GCC7zcqPo2poaALzdmVbQp9Dg=
open-cluster-management.io/cluster-proxy v0.1.2/go.mod h1:f4HVfparQqOJsPrh4fTA4uyWx5KJ7MG2AcuSRypedws=
open-cluster-management.io/managed-serviceaccount v0.2.1-0.20220427065210-de6a7b7b5be8 h1:foP5RkSec9DkUA8sJ5FLna5We8VxJyu0179id5zNXgA=
Expand Down
6 changes: 3 additions & 3 deletions pkg/cmd/create/sampleapp/exec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,17 +203,17 @@ var _ = ginkgo.Describe("deploy samepleapp to every managed cluster", func() {
subscriptionName = fmt.Sprintf("%s-subscription", o.SampleAppName)
)

if _, err = clusterClient.ClusterV1alpha1().Placements(testNamespace).Get(context.TODO(), placementResourceName, metav1.GetOptions{}); err != nil {
if _, err = clusterClient.ClusterV1beta1().Placements(testNamespace).Get(context.TODO(), placementResourceName, metav1.GetOptions{}); err != nil {
return fmt.Errorf(fmt.Sprintf("Missing Placement resource \"%s\" in namespace %s", placementResourceName, testNamespace))
}
fmt.Fprintf(streams.Out, "Placement resource \"%s\" created successfully in namespace %s.\n", placementResourceName, testNamespace)

if _, err = clusterClient.ClusterV1alpha1().ManagedClusterSets().Get(context.TODO(), managedClusterSetName, metav1.GetOptions{}); err != nil {
if _, err = clusterClient.ClusterV1beta2().ManagedClusterSets().Get(context.TODO(), managedClusterSetName, metav1.GetOptions{}); err != nil {
return fmt.Errorf(fmt.Sprintf("Missing ManagedClusterSet resource \"%s\"", managedClusterSetName))
}
fmt.Fprintf(streams.Out, "ManagedClusterSet resource \"%s\" created successfully.\n", managedClusterSetName)

if _, err = clusterClient.ClusterV1alpha1().ManagedClusterSetBindings(testNamespace).Get(context.TODO(), managedClusterSetBindingName, metav1.GetOptions{}); err != nil {
if _, err = clusterClient.ClusterV1beta2().ManagedClusterSetBindings(testNamespace).Get(context.TODO(), managedClusterSetBindingName, metav1.GetOptions{}); err != nil {
return fmt.Errorf(fmt.Sprintf("Missing ManagedClusterSetBinding resource \"%s\" in namespace %s", managedClusterSetBindingName, testNamespace))
}
fmt.Fprintf(streams.Out, "ManagedClusterSetBinding resource \"%s\" created successfully in namespace %s.\n", managedClusterSetBindingName, testNamespace)
Expand Down
22 changes: 22 additions & 0 deletions pkg/cmd/join/scenario/join/klusterlets.crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,28 @@ spec:
registrationImagePullSpec:
description: RegistrationImagePullSpec represents the desired image configuration of registration agent. quay.io/open-cluster-management.io/registration:latest will be used if unspecified.
type: string
workConfiguration:
description: WorkConfiguration contains the configuration of work
type: object
properties:
featureGates:
description: "FeatureGates represents the list of feature gates for work If it is set empty, default feature gates will be used. If it is set, featuregate/Foo is an example of one item in FeatureGates: 1. If featuregate/Foo does not exist, registration-operator will discard it 2. If featuregate/Foo exists and is false by default. It is now possible to set featuregate/Foo=[false|true] 3. If featuregate/Foo exists and is true by default. If a cluster-admin upgrading from 1 to 2 wants to continue having featuregate/Foo=false, \the can set featuregate/Foo=false before upgrading. Let's say the cluster-admin wants featuregate/Foo=false."
type: array
items:
type: object
required:
- feature
properties:
feature:
description: Feature is the key of feature gate. e.g. featuregate/Foo.
type: string
mode:
description: Mode is either Enable, Disable, "" where "" is Disable by default. In Enable mode, a valid feature gate `featuregate/Foo` will be set to "--featuregate/Foo=true". In Disable mode, a valid feature gate `featuregate/Foo` will be set to "--featuregate/Foo=false".
type: string
default: Disable
enum:
- Enable
- Disable
workImagePullSpec:
description: WorkImagePullSpec represents the desired image configuration of work agent. quay.io/open-cluster-management.io/work:latest will be used if unspecified.
type: string
Expand Down
10 changes: 6 additions & 4 deletions pkg/cmd/proxy/health/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"crypto/tls"
"crypto/x509"
"fmt"
"io/ioutil"
"io"
"net"
"net/http"
"net/url"
Expand All @@ -15,8 +15,6 @@ import (
"text/tabwriter"
"time"

"k8s.io/apimachinery/pkg/util/sets"

"github.com/pkg/errors"
"github.com/spf13/cobra"
"google.golang.org/grpc"
Expand All @@ -25,6 +23,7 @@ import (
"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
k8snet "k8s.io/apimachinery/pkg/util/net"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
Expand Down Expand Up @@ -101,6 +100,9 @@ func (o *Options) run(streams genericclioptions.IOStreams) error {
if err != nil {
return errors.Wrapf(err, "failed initializing proxy api client")
}

// TODO: fix this deprecated field AddOnConfiguration
// nolint:staticcheck
proxyConfig, err := proxyClient.ProxyV1alpha1().ManagedProxyConfigurations().
Get(context.TODO(), clusterAddon.Spec.AddOnConfiguration.CRName, metav1.GetOptions{})
if err != nil {
Expand Down Expand Up @@ -275,7 +277,7 @@ func (o *Options) visit(
}

end := time.Now()
data, _ := ioutil.ReadAll(resp.Body)
data, _ := io.ReadAll(resp.Body)
if "ok" == string(data) {
health = "True"
latency = end.Sub(start).String()
Expand Down
6 changes: 4 additions & 2 deletions pkg/cmd/proxy/kubectl/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ package kubectl
import (
"context"
"fmt"
"io/ioutil"
"os"
"os/exec"
"strings"
Expand Down Expand Up @@ -172,6 +171,9 @@ func getProxyConfig(hubRestConfig *rest.Config, streams genericclioptions.IOStre
if err != nil {
return nil, errors.Wrapf(err, "failed initializing proxy api client")
}

// TODO: fix this deprecated field AddOnConfiguration
// nolint:staticcheck
proxyConfig, err := proxyClient.ProxyV1alpha1().ManagedProxyConfigurations().
Get(context.TODO(), clusterAddon.Spec.AddOnConfiguration.CRName, metav1.GetOptions{})
if err != nil {
Expand Down Expand Up @@ -240,7 +242,7 @@ func genTmpKubeconfig(cluster string, msaToken string) (string, error) {
}

tmpFile := fmt.Sprintf("/tmp/%s-%s.kubeconfig", cluster, uuid.New().String())
if err := ioutil.WriteFile(tmpFile, kubeconfigContent, 0644); err != nil {
if err := os.WriteFile(tmpFile, kubeconfigContent, 0644); err != nil {
return "", err
}

Expand Down
8 changes: 6 additions & 2 deletions vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -990,8 +990,8 @@ k8s.io/utils/internal/third_party/forked/golang/net
k8s.io/utils/net
k8s.io/utils/pointer
k8s.io/utils/trace
# open-cluster-management.io/api v0.8.0
## explicit; go 1.18
# open-cluster-management.io/api v0.9.1-0.20221116150238-55691c2c5f04
## explicit; go 1.19
open-cluster-management.io/api/addon/v1alpha1
open-cluster-management.io/api/client/addon/clientset/versioned
open-cluster-management.io/api/client/addon/clientset/versioned/scheme
Expand All @@ -1001,17 +1001,21 @@ open-cluster-management.io/api/client/cluster/clientset/versioned/scheme
open-cluster-management.io/api/client/cluster/clientset/versioned/typed/cluster/v1
open-cluster-management.io/api/client/cluster/clientset/versioned/typed/cluster/v1alpha1
open-cluster-management.io/api/client/cluster/clientset/versioned/typed/cluster/v1beta1
open-cluster-management.io/api/client/cluster/clientset/versioned/typed/cluster/v1beta2
open-cluster-management.io/api/client/operator/clientset/versioned
open-cluster-management.io/api/client/operator/clientset/versioned/scheme
open-cluster-management.io/api/client/operator/clientset/versioned/typed/operator/v1
open-cluster-management.io/api/client/work/clientset/versioned
open-cluster-management.io/api/client/work/clientset/versioned/scheme
open-cluster-management.io/api/client/work/clientset/versioned/typed/work/v1
open-cluster-management.io/api/client/work/clientset/versioned/typed/work/v1alpha1
open-cluster-management.io/api/cluster/v1
open-cluster-management.io/api/cluster/v1alpha1
open-cluster-management.io/api/cluster/v1beta1
open-cluster-management.io/api/cluster/v1beta2
open-cluster-management.io/api/operator/v1
open-cluster-management.io/api/work/v1
open-cluster-management.io/api/work/v1alpha1
# open-cluster-management.io/cluster-proxy v0.1.2
## explicit; go 1.16
open-cluster-management.io/cluster-proxy/pkg/apis/proxy/v1alpha1
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit b8fc958

Please sign in to comment.