Skip to content

Commit

Permalink
Merge upstream stream changes (#99)
Browse files Browse the repository at this point in the history
* Remove codecov token in actions. (#174)

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

* Use k8s 1.29 client libs (#175)

Signed-off-by: Tamal Saha <[email protected]>

* Fix the verify error of logger. (#177)

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

* Upgrade chart version to 0.4.0. (#178)

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

* Update workflows. (#179)

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

* Simplify installer watchers (#180)

Signed-off-by: Tamal Saha <[email protected]>

* Remove unused code (#181)

Signed-off-by: Tamal Saha <[email protected]>

* Fix LB type proxy server setup in chart (#182)

Signed-off-by: Tamal Saha <[email protected]>

* Use default rollingout strategy. (#184)

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

* Add the hash value of signer into subject organizationunits (#183)

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

* Change examples to md format to reduce dependences. (#185)

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

* Update stolostronagent.

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

---------

Signed-off-by: xuezhaojun <[email protected]>
Signed-off-by: Tamal Saha <[email protected]>
Signed-off-by: GitHub <[email protected]>
Co-authored-by: Tamal Saha <[email protected]>
  • Loading branch information
xuezhaojun and tamalsaha authored Mar 20, 2024
1 parent e35ccaf commit 6cde007
Show file tree
Hide file tree
Showing 33 changed files with 427 additions and 632 deletions.
11 changes: 3 additions & 8 deletions .github/workflows/go-postsubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,8 @@ on:

env:
# Common versions
GO_VERSION: '1.20'
GO_VERSION: '1.21'
GO_REQUIRED_MIN_VERSION: ''
defaults:
run:
working-directory: go/src/open-cluster-management.io/cluster-proxy

jobs:
images:
Expand All @@ -24,10 +21,9 @@ jobs:
arch: [ amd64, arm64 ]
steps:
- name: checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 1
path: go/src/open-cluster-management.io/cluster-proxy
- name: install Go
uses: actions/setup-go@v2
with:
Expand All @@ -51,10 +47,9 @@ jobs:
needs: [ images ]
steps:
- name: checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 1
path: go/src/open-cluster-management.io/cluster-proxy
- name: create
run: |
echo ${{ secrets.DOCKER_PASSWORD }} | docker login quay.io --username ${{ secrets.DOCKER_USER }} --password-stdin
Expand Down
15 changes: 7 additions & 8 deletions .github/workflows/go-presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:

env:
# Common versions
GO_VERSION: '1.20'
GO_VERSION: '1.21'
GO_REQUIRED_MIN_VERSION: ''

jobs:
Expand All @@ -22,7 +22,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: install Go
uses: actions/setup-go@v2
with:
Expand All @@ -34,15 +34,15 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Linelint
uses: fernandrone/[email protected]
verify:
name: verify
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: install Go
uses: actions/setup-go@v2
with:
Expand All @@ -54,7 +54,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: install Go
uses: actions/setup-go@v2
with:
Expand All @@ -64,7 +64,6 @@ jobs:
- name: report coverage
uses: codecov/codecov-action@v3
with:
token: ${{secrets.CODECOV_UPLOAD_TOKEN}}
files: ./cover.out
flags: unit
name: unit
Expand All @@ -76,7 +75,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: install Go
uses: actions/setup-go@v2
with:
Expand All @@ -89,7 +88,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: install Go
uses: actions/setup-go@v2
with:
Expand Down
34 changes: 17 additions & 17 deletions .github/workflows/go-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,20 @@ on:
- 'v*.*.*'
env:
# Common versions
GO_VERSION: '1.20'
GO_VERSION: '1.21'
GO_REQUIRED_MIN_VERSION: ''
GITHUB_REF: ${{ github.ref }}
CHART_NAME: 'cluster-proxy'

defaults:
run:
working-directory: go/src/open-cluster-management.io/cluster-proxy

jobs:
env:
name: prepare release env
runs-on: ubuntu-latest
steps:
- name: checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 1
path: go/src/open-cluster-management.io/cluster-proxy
- name: get release version
run: |
echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
Expand All @@ -48,10 +43,9 @@ jobs:
arch: [ amd64, arm64 ]
steps:
- name: checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 1
path: go/src/open-cluster-management.io/cluster-proxy
- name: install Go
uses: actions/setup-go@v2
with:
Expand All @@ -75,10 +69,9 @@ jobs:
needs: [ env, images ]
steps:
- name: checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 1
path: go/src/open-cluster-management.io/cluster-proxy
- name: create
run: |
echo ${{ secrets.DOCKER_PASSWORD }} | docker login quay.io --username ${{ secrets.DOCKER_USER }} --password-stdin
Expand All @@ -100,10 +93,9 @@ jobs:
needs: [ env, image-manifest ]
steps:
- name: checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 1
path: go/src/open-cluster-management.io/cluster-proxy
- name: setup helm
uses: azure/setup-helm@v1
- name: chart package
Expand All @@ -112,12 +104,20 @@ jobs:
pushd release
helm package ../charts/${{ env.CHART_NAME }}/
popd
- name: generate changelog
run: |
echo "# Cluster Proxy ${{ needs.env.outputs.RELEASE_VERSION }}" > /home/runner/work/changelog.txt
- name: publish release
uses: ncipollo/release-action@v1
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag: ${{ env.RELEASE_VERSION }}
artifacts: "go/src/open-cluster-management.io/cluster-proxy/release/*.tgz"
token: ${{ secrets.GITHUB_TOKEN }}
body_path: /home/runner/work/changelog.txt
files: |
release/*.tgz
draft: true
prerelease: false
generate_release_notes: true
- name: submit charts to OCM chart repo
uses: actions/github-script@v6
with:
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ IMAGE_NAME = cluster-proxy
IMAGE_TAG ?= latest
E2E_TEST_CLUSTER_NAME ?= loopback
# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
CRD_OPTIONS ?= "crd:trivialVersions=true,preserveUnknownFields=false"
CRD_OPTIONS ?= "crd:crdVersions={v1},allowDangerousTypes=true,generateEmbeddedObjectMeta=true"

# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
Expand Down Expand Up @@ -95,7 +95,7 @@ undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/confi

CONTROLLER_GEN = $(shell pwd)/bin/controller-gen
controller-gen: ## Download controller-gen locally if necessary.
$(call go-get-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/controller-gen@v0.4.1)
$(call go-get-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/controller-gen@v0.14.0)

KUSTOMIZE = $(shell pwd)/bin/kustomize
kustomize: ## Download kustomize locally if necessary.
Expand All @@ -116,7 +116,7 @@ rm -rf $$TMP_DIR ;\
endef

client-gen:
go install k8s.io/code-generator/cmd/client-gen@v0.23.0
go install k8s.io/code-generator/cmd/client-gen@v0.29.2
go install sigs.k8s.io/apiserver-runtime/tools/[email protected]
apiserver-runtime-gen \
--module open-cluster-management.io/cluster-proxy \
Expand Down
2 changes: 1 addition & 1 deletion charts/cluster-proxy/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ apiVersion: v2
name: cluster-proxy
description: A Helm chart for Cluster-Proxy OCM Addon
type: application
version: 0.3.0
version: 0.4.0
appVersion: 1.0.0
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ spec:
type: Hostname
hostname:
value: {{ .Values.proxyServer.entrypointAddress }}
{{- else if .Values.entrypointLoadBalancer }}
{{- else if .Values.proxyServer.entrypointLoadBalancer }}
type: LoadBalancerService
loadBalancerService: {}
{{- else }}
Expand Down
4 changes: 2 additions & 2 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import (
"k8s.io/apimachinery/pkg/labels"
"k8s.io/client-go/rest"
clusterv1client "open-cluster-management.io/api/client/cluster/clientset/versioned"
clusterv1beta2 "open-cluster-management.io/api/cluster/v1beta2"
"open-cluster-management.io/cluster-proxy/pkg/generated/clientset/versioned"
"open-cluster-management.io/cluster-proxy/pkg/util"
clustersdkv1beta2 "open-cluster-management.io/sdk-go/pkg/apis/cluster/v1beta2"
)

func GetProxyHost(ctx context.Context, kubeconfig *rest.Config, clusterName string, namespace string, serviceName string) (string, error) {
Expand Down Expand Up @@ -40,7 +40,7 @@ func GetProxyHost(ctx context.Context, kubeconfig *rest.Config, clusterName stri
if err != nil {
return "", err
}
selector, err := clusterv1beta2.BuildClusterSelector(set)
selector, err := clustersdkv1beta2.BuildClusterSelector(set)
if err != nil {
return "", err
}
Expand Down
15 changes: 7 additions & 8 deletions cmd/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
# Build the manager binary
FROM golang:1.20 as builder
FROM golang:1.21 as builder

WORKDIR /workspace

ARG APISERVER_NETWORK_PROXY_VERSION=0.1.6
ARG APISERVER_NETWORK_PROXY_VERSION=0.29.0
ARG KUBECTL_VERSION=v1.23.1
ARG ADDON_AGENT_IMAGE_NAME

# Build Apiserver-network-proxy binaries
RUN GOOS=linux GOARCH=amd64 CGO_ENABLED=0 \
wget https://github.com/kubernetes-sigs/apiserver-network-proxy/archive/refs/tags/v${APISERVER_NETWORK_PROXY_VERSION}.tar.gz \
RUN wget https://github.com/kubernetes-sigs/apiserver-network-proxy/archive/refs/tags/v${APISERVER_NETWORK_PROXY_VERSION}.tar.gz \
&& tar xzvf v${APISERVER_NETWORK_PROXY_VERSION}.tar.gz \
&& cd apiserver-network-proxy-${APISERVER_NETWORK_PROXY_VERSION} \
&& go build -o /workspace/proxy-server ./cmd/server/ \
&& go build -o /workspace/proxy-agent ./cmd/agent/ \
&& go build -o /workspace/proxy-test-client ./cmd/test-client/ \
&& go build -o /workspace/proxy-test-server ./cmd/test-server/ \
&& CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o /workspace/proxy-server ./cmd/server/ \
&& CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o /workspace/proxy-agent ./cmd/agent/ \
&& CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o /workspace/proxy-test-client ./cmd/test-client/ \
&& CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o /workspace/proxy-test-server ./cmd/test-server/ \
&& cd /workspace \
&& curl -LO "https://dl.k8s.io/release/${KUBECTL_VERSION}/bin/linux/amd64/kubectl" \
&& chmod a+x kubectl
Expand Down
2 changes: 1 addition & 1 deletion cmd/Dockerfile.rhtap
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Build the manager binary
# This dockerfile only used in middle stream build, without downloading and building APISERVER_NETWORK_PROXY_VERSION
FROM brew.registry.redhat.io/rh-osbs/openshift-golang-builder:rhel_8_1.19 as builder
FROM brew.registry.redhat.io/rh-osbs/openshift-golang-builder:rhel_8_1.21 as builder

WORKDIR /workspace
COPY . .
Expand Down
4 changes: 2 additions & 2 deletions cmd/addon-agent/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/tools/clientcmd"
"k8s.io/klog/v2"
"k8s.io/klog/v2/klogr"
"k8s.io/klog/v2/textlogger"
"open-cluster-management.io/addon-framework/pkg/lease"
"open-cluster-management.io/cluster-proxy/pkg/common"
"open-cluster-management.io/cluster-proxy/pkg/util"
Expand All @@ -31,7 +31,7 @@ const envKeyPodNamespace = "POD_NAMESPACE"

func main() {

logger := klogr.New()
logger := textlogger.NewLogger(textlogger.NewConfig())
klog.SetOutput(os.Stdout)
klog.InitFlags(flag.CommandLine)
flag.StringVar(&hubKubeconfig, "hub-kubeconfig", "",
Expand Down
18 changes: 4 additions & 14 deletions cmd/addon-manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,11 @@ import (
"k8s.io/client-go/kubernetes"
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
"k8s.io/klog/v2"
"k8s.io/klog/v2/klogr"
"k8s.io/klog/v2/textlogger"
"open-cluster-management.io/addon-framework/pkg/addonmanager"
addonutil "open-cluster-management.io/addon-framework/pkg/utils"
addonv1alpha1 "open-cluster-management.io/api/addon/v1alpha1"
"open-cluster-management.io/api/client/addon/clientset/versioned"
addonclient "open-cluster-management.io/api/client/addon/clientset/versioned"
"open-cluster-management.io/api/client/addon/informers/externalversions"
clusterv1beta2 "open-cluster-management.io/api/cluster/v1beta2"
proxyv1alpha1 "open-cluster-management.io/cluster-proxy/pkg/apis/proxy/v1alpha1"
"open-cluster-management.io/cluster-proxy/pkg/config"
Expand All @@ -47,6 +45,7 @@ import (
"open-cluster-management.io/cluster-proxy/pkg/proxyserver/operator/authentication/selfsigned"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/healthz"
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"
//+kubebuilder:scaffold:imports
)

Expand All @@ -72,7 +71,7 @@ func main() {
var agentInstallAll bool
var enableKubeApiProxy bool

logger := klogr.New()
logger := textlogger.NewLogger(textlogger.NewConfig())
klog.SetOutput(os.Stdout)
klog.InitFlags(flag.CommandLine)
flag.StringVar(&metricsAddr, "metrics-bind-address", ":58080", "The address the metric endpoint binds to.")
Expand Down Expand Up @@ -102,8 +101,7 @@ func main() {

mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
Scheme: scheme,
MetricsBindAddress: metricsAddr,
Port: 9443,
Metrics: metricsserver.Options{BindAddress: metricsAddr},
HealthProbeBindAddress: probeAddr,
LeaderElection: enableLeaderElection,
LeaderElectionID: "cluster-proxy-addon-manager",
Expand All @@ -113,12 +111,6 @@ func main() {
os.Exit(1)
}

client, err := versioned.NewForConfig(mgr.GetConfig())
if err != nil {
setupLog.Error(err, "unable to set up addon client")
os.Exit(1)
}

nativeClient, err := kubernetes.NewForConfig(mgr.GetConfig())
if err != nil {
setupLog.Error(err, "unable to set up kubernetes native client")
Expand Down Expand Up @@ -146,7 +138,6 @@ func main() {
os.Exit(1)
}

informerFactory := externalversions.NewSharedInformerFactory(client, 0)
nativeInformer := informers.NewSharedInformerFactoryWithOptions(nativeClient, 0)

// loading self-signer
Expand Down Expand Up @@ -211,7 +202,6 @@ func main() {

ctx, cancel := context.WithCancel(ctrl.SetupSignalHandler())
defer cancel()
go informerFactory.Start(ctx.Done())
go nativeInformer.Start(ctx.Done())
go func() {
if err := addonManager.Start(ctx); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion cmd/pure.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Build the manager binary
# This dockerfile only used in middle stream build, without downloading and building APISERVER_NETWORK_PROXY_VERSION
FROM registry.ci.openshift.org/stolostron/builder:go1.19-linux AS builder
FROM registry.ci.openshift.org/stolostron/builder:go1.21-linux AS builder

WORKDIR /workspace
COPY . .
Expand Down
Loading

0 comments on commit 6cde007

Please sign in to comment.