提交 49ccf002 编写于 作者: D Darren Shepherd

Embed channelserver in rancher

上级 1c3629fb
...@@ -7,7 +7,6 @@ ENV CATTLE_HELM_VERSION v2.16.8-rancher1 ...@@ -7,7 +7,6 @@ ENV CATTLE_HELM_VERSION v2.16.8-rancher1
ENV CATTLE_MACHINE_VERSION v0.15.0-rancher54 ENV CATTLE_MACHINE_VERSION v0.15.0-rancher54
ENV CATTLE_K3S_VERSION v1.19.8+k3s1 ENV CATTLE_K3S_VERSION v1.19.8+k3s1
ENV CATTLE_ETCD_VERSION v3.4.3 ENV CATTLE_ETCD_VERSION v3.4.3
ENV CATTLE_CHANNELSERVER_VERSION v0.5.0
# version used by helm plugin install script # version used by helm plugin install script
ENV CATTLE_HELM_UNITTEST_VERSION v0.1.7-rancher3 ENV CATTLE_HELM_UNITTEST_VERSION v0.1.7-rancher3
# helm 3 version # helm 3 version
...@@ -47,9 +46,6 @@ ENV HELM_URL_V2_amd64=https://github.com/rancher/helm/releases/download/${CATTLE ...@@ -47,9 +46,6 @@ ENV HELM_URL_V2_amd64=https://github.com/rancher/helm/releases/download/${CATTLE
K3S_URL_amd64=https://github.com/rancher/k3s/releases/download/${CATTLE_K3S_VERSION}/k3s \ K3S_URL_amd64=https://github.com/rancher/k3s/releases/download/${CATTLE_K3S_VERSION}/k3s \
K3S_URL_arm64=https://github.com/rancher/k3s/releases/download/${CATTLE_K3S_VERSION}/k3s-arm64 \ K3S_URL_arm64=https://github.com/rancher/k3s/releases/download/${CATTLE_K3S_VERSION}/k3s-arm64 \
K3S_URL=K3S_URL_${ARCH} \ K3S_URL=K3S_URL_${ARCH} \
CHANNELSERVER_URL_amd64=https://github.com/rancher/channelserver/releases/download/${CATTLE_CHANNELSERVER_VERSION}/channelserver-amd64 \
CHANNELSERVER_URL_arm64=https://github.com/rancher/channelserver/releases/download/${CATTLE_CHANNELSERVER_VERSION}/channelserver-arm64 \
CHANNELSERVER_URL=CHANNELSERVER_URL_${ARCH} \
ETCD_URL_amd64=https://github.com/etcd-io/etcd/releases/download/${CATTLE_ETCD_VERSION}/etcd-${CATTLE_ETCD_VERSION}-linux-amd64.tar.gz \ ETCD_URL_amd64=https://github.com/etcd-io/etcd/releases/download/${CATTLE_ETCD_VERSION}/etcd-${CATTLE_ETCD_VERSION}-linux-amd64.tar.gz \
ETCD_URL_arm64=https://github.com/etcd-io/etcd/releases/download/${CATTLE_ETCD_VERSION}/etcd-${CATTLE_ETCD_VERSION}-linux-arm64.tar.gz \ ETCD_URL_arm64=https://github.com/etcd-io/etcd/releases/download/${CATTLE_ETCD_VERSION}/etcd-${CATTLE_ETCD_VERSION}-linux-arm64.tar.gz \
ETCD_URL=ETCD_URL_${ARCH} \ ETCD_URL=ETCD_URL_${ARCH} \
...@@ -80,10 +76,9 @@ RUN mkdir /usr/tmp && \ ...@@ -80,10 +76,9 @@ RUN mkdir /usr/tmp && \
mv /usr/tmp/helm /usr/bin/helm_v3 && \ mv /usr/tmp/helm /usr/bin/helm_v3 && \
chmod +x /usr/bin/kustomize chmod +x /usr/bin/kustomize
RUN curl -sLf ${!CHANNELSERVER_URL} > /usr/bin/channelserver && \ RUN curl -sLf ${!K3S_URL} > /usr/bin/k3s && \
curl -sLf ${!K3S_URL} > /usr/bin/k3s && \
curl -sfL ${!ETCD_URL} | tar xvzf - --strip-components=1 -C /usr/bin/ etcd-${CATTLE_ETCD_VERSION}-linux-${ARCH}/etcd && \ curl -sfL ${!ETCD_URL} | tar xvzf - --strip-components=1 -C /usr/bin/ etcd-${CATTLE_ETCD_VERSION}-linux-${ARCH}/etcd && \
chmod +x /usr/bin/k3s /usr/bin/channelserver && \ chmod +x /usr/bin/k3s && \
mkdir -p /go/src/github.com/rancher/rancher/.kube && \ mkdir -p /go/src/github.com/rancher/rancher/.kube && \
ln -s /etc/rancher/k3s/k3s.yaml /go/src/github.com/rancher/rancher/.kube/k3s.yaml ln -s /etc/rancher/k3s/k3s.yaml /go/src/github.com/rancher/rancher/.kube/k3s.yaml
......
...@@ -94,6 +94,7 @@ require ( ...@@ -94,6 +94,7 @@ require (
github.com/prometheus/client_model v0.2.0 github.com/prometheus/client_model v0.2.0
github.com/prometheus/common v0.14.0 github.com/prometheus/common v0.14.0
github.com/rancher/apiserver v0.0.0-20210209001659-a17289640582 github.com/rancher/apiserver v0.0.0-20210209001659-a17289640582
github.com/rancher/channelserver v0.5.1-0.20210414044409-8ffd1e007042
github.com/rancher/dynamiclistener v0.2.1-0.20200910203214-85f32491cb09 github.com/rancher/dynamiclistener v0.2.1-0.20200910203214-85f32491cb09
github.com/rancher/eks-operator v1.0.6-rc1 github.com/rancher/eks-operator v1.0.6-rc1
github.com/rancher/gke-operator v1.0.1-rc6 github.com/rancher/gke-operator v1.0.1-rc6
...@@ -109,7 +110,7 @@ require ( ...@@ -109,7 +110,7 @@ require (
github.com/rancher/security-scan v0.1.7-0.20200222041501-f7377f127168 github.com/rancher/security-scan v0.1.7-0.20200222041501-f7377f127168
github.com/rancher/steve v0.0.0-20210318171316-376934558c5b github.com/rancher/steve v0.0.0-20210318171316-376934558c5b
github.com/rancher/system-upgrade-controller/pkg/apis v0.0.0-20200825145542-a04e2061be24 github.com/rancher/system-upgrade-controller/pkg/apis v0.0.0-20200825145542-a04e2061be24
github.com/rancher/wrangler v0.7.3-0.20210407025123-cf9bb4f55cee github.com/rancher/wrangler v0.8.0
github.com/robfig/cron v1.1.0 github.com/robfig/cron v1.1.0
github.com/satori/go.uuid v1.2.0 github.com/satori/go.uuid v1.2.0
github.com/segmentio/kafka-go v0.0.0-20190411192201-218fd49cff39 github.com/segmentio/kafka-go v0.0.0-20190411192201-218fd49cff39
......
...@@ -502,6 +502,8 @@ github.com/google/go-cmp v0.5.4 h1:L8R9j+yAqZuZjsqh/z+F1NCffTKKLShY6zXTItVIZ8M= ...@@ -502,6 +502,8 @@ github.com/google/go-cmp v0.5.4 h1:L8R9j+yAqZuZjsqh/z+F1NCffTKKLShY6zXTItVIZ8M=
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-github v17.0.0+incompatible h1:N0LgJ1j65A7kfXrZnUDaYCs/Sf4rEjNlfyDHW9dolSY= github.com/google/go-github v17.0.0+incompatible h1:N0LgJ1j65A7kfXrZnUDaYCs/Sf4rEjNlfyDHW9dolSY=
github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ= github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ=
github.com/google/go-github/v29 v29.0.3 h1:IktKCTwU//aFHnpA+2SLIi7Oo9uhAzgsdZNbcAqhgdc=
github.com/google/go-github/v29 v29.0.3/go.mod h1:CHKiKKPHJ0REzfwc14QMklvtHwCveD0PxlMjLlzAM5E=
github.com/google/go-querystring v0.0.0-20140804062624-30f7a39f4a21/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= github.com/google/go-querystring v0.0.0-20140804062624-30f7a39f4a21/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk= github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk=
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
...@@ -540,8 +542,9 @@ github.com/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e/go.mod h1:wJfORR ...@@ -540,8 +542,9 @@ github.com/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e/go.mod h1:wJfORR
github.com/gopherjs/gopherjs v0.0.0-20191106031601-ce3c9ade29de h1:F7WD09S8QB4LrkEpka0dFPLSotH11HRpCsLIbIcJ7sU= github.com/gopherjs/gopherjs v0.0.0-20191106031601-ce3c9ade29de h1:F7WD09S8QB4LrkEpka0dFPLSotH11HRpCsLIbIcJ7sU=
github.com/gopherjs/gopherjs v0.0.0-20191106031601-ce3c9ade29de/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gopherjs/gopherjs v0.0.0-20191106031601-ce3c9ade29de/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
github.com/gorilla/handlers v0.0.0-20150720190736-60c7bfde3e33 h1:893HsJqtxp9z1SF76gg6hY70hRY1wVlTSnC/h1yUDCo=
github.com/gorilla/handlers v0.0.0-20150720190736-60c7bfde3e33/go.mod h1:Qkdc/uu4tH4g6mTK6auzZ766c4CA0Ng8+o/OAirnOIQ= github.com/gorilla/handlers v0.0.0-20150720190736-60c7bfde3e33/go.mod h1:Qkdc/uu4tH4g6mTK6auzZ766c4CA0Ng8+o/OAirnOIQ=
github.com/gorilla/handlers v1.4.2 h1:0QniY0USkHQ1RGCLfKxeNHK9bkDHGRYGNDFBCS+YARg=
github.com/gorilla/handlers v1.4.2/go.mod h1:Qkdc/uu4tH4g6mTK6auzZ766c4CA0Ng8+o/OAirnOIQ=
github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
github.com/gorilla/mux v1.7.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= github.com/gorilla/mux v1.7.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
...@@ -931,6 +934,8 @@ github.com/rackspace/gophercloud v0.0.0-20150408191457-ce0f487f6747/go.mod h1:4b ...@@ -931,6 +934,8 @@ github.com/rackspace/gophercloud v0.0.0-20150408191457-ce0f487f6747/go.mod h1:4b
github.com/rancher/apiserver v0.0.0-20201023000256-1a0a904f9197/go.mod h1:8W0EwaR9dH5NDFw6mpAX437D0q+EZqKWbZyX71+z2WI= github.com/rancher/apiserver v0.0.0-20201023000256-1a0a904f9197/go.mod h1:8W0EwaR9dH5NDFw6mpAX437D0q+EZqKWbZyX71+z2WI=
github.com/rancher/apiserver v0.0.0-20210209001659-a17289640582 h1:J9ubiCnLYwIHS++Qwxnwq8dwZzZH9GF7yvN0AmFWd14= github.com/rancher/apiserver v0.0.0-20210209001659-a17289640582 h1:J9ubiCnLYwIHS++Qwxnwq8dwZzZH9GF7yvN0AmFWd14=
github.com/rancher/apiserver v0.0.0-20210209001659-a17289640582/go.mod h1:8W0EwaR9dH5NDFw6mpAX437D0q+EZqKWbZyX71+z2WI= github.com/rancher/apiserver v0.0.0-20210209001659-a17289640582/go.mod h1:8W0EwaR9dH5NDFw6mpAX437D0q+EZqKWbZyX71+z2WI=
github.com/rancher/channelserver v0.5.1-0.20210414044409-8ffd1e007042 h1:ZgfXsHJm6LmrzH0Znbu5n08BdMzhL7uRoRmTf/WYLgI=
github.com/rancher/channelserver v0.5.1-0.20210414044409-8ffd1e007042/go.mod h1:1/9aBa8mXEIinRiT6Qlv/zbt6Nv9uorv+kFVNYvpmiI=
github.com/rancher/client-go v1.20.0-rancher.1 h1:B85UDTIx+0XgOyv0obL9HJSNdY3mNBi1+wm26TOQZ8o= github.com/rancher/client-go v1.20.0-rancher.1 h1:B85UDTIx+0XgOyv0obL9HJSNdY3mNBi1+wm26TOQZ8o=
github.com/rancher/client-go v1.20.0-rancher.1/go.mod h1:UTdyXFcu9VZV4qQRKGXCa0KdMX4HTCXClRs4s7yFdDQ= github.com/rancher/client-go v1.20.0-rancher.1/go.mod h1:UTdyXFcu9VZV4qQRKGXCa0KdMX4HTCXClRs4s7yFdDQ=
github.com/rancher/dynamiclistener v0.2.1-0.20200714201033-9c1939da3af9/go.mod h1:qr0QfhwzcVCR+Ao9WyfnE+jmOpfEAdRhXtNOZGJ3nCQ= github.com/rancher/dynamiclistener v0.2.1-0.20200714201033-9c1939da3af9/go.mod h1:qr0QfhwzcVCR+Ao9WyfnE+jmOpfEAdRhXtNOZGJ3nCQ=
...@@ -948,7 +953,6 @@ github.com/rancher/lasso v0.0.0-20200427171700-e0509f89f319/go.mod h1:6Dw19z1lDI ...@@ -948,7 +953,6 @@ github.com/rancher/lasso v0.0.0-20200427171700-e0509f89f319/go.mod h1:6Dw19z1lDI
github.com/rancher/lasso v0.0.0-20200515155337-a34e1e26ad91/go.mod h1:G6Vv2aj6xB2YjTVagmu4NkhBvbE8nBcGykHRENH6arI= github.com/rancher/lasso v0.0.0-20200515155337-a34e1e26ad91/go.mod h1:G6Vv2aj6xB2YjTVagmu4NkhBvbE8nBcGykHRENH6arI=
github.com/rancher/lasso v0.0.0-20200820172840-0e4cc0ef5cb0/go.mod h1:OhBBBO1pBwYp0hacWdnvSGOj+XE9yMLOLnaypIlic18= github.com/rancher/lasso v0.0.0-20200820172840-0e4cc0ef5cb0/go.mod h1:OhBBBO1pBwYp0hacWdnvSGOj+XE9yMLOLnaypIlic18=
github.com/rancher/lasso v0.0.0-20200905045615-7fcb07d6a20b/go.mod h1:OhBBBO1pBwYp0hacWdnvSGOj+XE9yMLOLnaypIlic18= github.com/rancher/lasso v0.0.0-20200905045615-7fcb07d6a20b/go.mod h1:OhBBBO1pBwYp0hacWdnvSGOj+XE9yMLOLnaypIlic18=
github.com/rancher/lasso v0.0.0-20210407025055-18a00567c734/go.mod h1:OhBBBO1pBwYp0hacWdnvSGOj+XE9yMLOLnaypIlic18=
github.com/rancher/lasso v0.0.0-20210408231703-9ddd9378d08d h1:vfjPEF6M7Jf1/zK1xF7z2drLfniooKcgDQdoXO5+U7w= github.com/rancher/lasso v0.0.0-20210408231703-9ddd9378d08d h1:vfjPEF6M7Jf1/zK1xF7z2drLfniooKcgDQdoXO5+U7w=
github.com/rancher/lasso v0.0.0-20210408231703-9ddd9378d08d/go.mod h1:OhBBBO1pBwYp0hacWdnvSGOj+XE9yMLOLnaypIlic18= github.com/rancher/lasso v0.0.0-20210408231703-9ddd9378d08d/go.mod h1:OhBBBO1pBwYp0hacWdnvSGOj+XE9yMLOLnaypIlic18=
github.com/rancher/machine v0.15.0-rancher25 h1:i78iohBm9QLmxHOMM1ZssYwSNIObPdDUQjZ9h1mo8Jc= github.com/rancher/machine v0.15.0-rancher25 h1:i78iohBm9QLmxHOMM1ZssYwSNIObPdDUQjZ9h1mo8Jc=
...@@ -982,8 +986,8 @@ github.com/rancher/wrangler v0.6.2-0.20200714200521-c61fae623942/go.mod h1:8LdIq ...@@ -982,8 +986,8 @@ github.com/rancher/wrangler v0.6.2-0.20200714200521-c61fae623942/go.mod h1:8LdIq
github.com/rancher/wrangler v0.6.2-0.20200820173016-2068de651106/go.mod h1:iKqQcYs4YSDjsme52OZtQU4jHPmLlIiM93aj2c8c/W8= github.com/rancher/wrangler v0.6.2-0.20200820173016-2068de651106/go.mod h1:iKqQcYs4YSDjsme52OZtQU4jHPmLlIiM93aj2c8c/W8=
github.com/rancher/wrangler v0.7.1/go.mod h1:goezjesEKwMxHLfltdjg9DW0xWV7txQee6vOuSDqXAI= github.com/rancher/wrangler v0.7.1/go.mod h1:goezjesEKwMxHLfltdjg9DW0xWV7txQee6vOuSDqXAI=
github.com/rancher/wrangler v0.7.3-0.20201020003736-e86bc912dfac/go.mod h1:goezjesEKwMxHLfltdjg9DW0xWV7txQee6vOuSDqXAI= github.com/rancher/wrangler v0.7.3-0.20201020003736-e86bc912dfac/go.mod h1:goezjesEKwMxHLfltdjg9DW0xWV7txQee6vOuSDqXAI=
github.com/rancher/wrangler v0.7.3-0.20210407025123-cf9bb4f55cee h1:xSaIJ8MRj7wgcYSRaTBDiC90jIyOl3+LUMAshNIWozg= github.com/rancher/wrangler v0.8.0 h1:jGWr7ES0KwZU/8zB6lte0z4QB7hFcspaXPTvGmrvHok=
github.com/rancher/wrangler v0.7.3-0.20210407025123-cf9bb4f55cee/go.mod h1:JJ68YG6bgMGArlEZrrif9gwIJEtGsk44g51Eovael9E= github.com/rancher/wrangler v0.8.0/go.mod h1:zSV5oh3+YZboilwcJmFHO3J6FZba82BTQft1b6ijx2I=
github.com/rancher/wrangler-api v0.6.1-0.20200427172631-a7c2f09b783e/go.mod h1:2lcWR98q8HU3U4mVETnXc8quNG0uXxrt8vKd6cAa/30= github.com/rancher/wrangler-api v0.6.1-0.20200427172631-a7c2f09b783e/go.mod h1:2lcWR98q8HU3U4mVETnXc8quNG0uXxrt8vKd6cAa/30=
github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
github.com/remyoudompheng/bigfft v0.0.0-20170806203942-52369c62f446/go.mod h1:uYEyJGbgTkfkS4+E/PavXkNJcbFIpEtjt2B0KDQ5+9M= github.com/remyoudompheng/bigfft v0.0.0-20170806203942-52369c62f446/go.mod h1:uYEyJGbgTkfkS4+E/PavXkNJcbFIpEtjt2B0KDQ5+9M=
...@@ -1102,6 +1106,7 @@ github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtX ...@@ -1102,6 +1106,7 @@ github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtX
github.com/urfave/cli v1.22.2 h1:gsqYFH8bb9ekPA12kRo0hfjngWQjkJPlN9R0N78BoUo= github.com/urfave/cli v1.22.2 h1:gsqYFH8bb9ekPA12kRo0hfjngWQjkJPlN9R0N78BoUo=
github.com/urfave/cli v1.22.2/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= github.com/urfave/cli v1.22.2/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
github.com/urfave/cli/v2 v2.1.1/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ= github.com/urfave/cli/v2 v2.1.1/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ=
github.com/urfave/cli/v2 v2.2.0/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ=
github.com/urfave/negroni v1.0.0/go.mod h1:Meg73S6kFm/4PpbYdq35yYWoCZ9mS/YSx+lKnmiohz4= github.com/urfave/negroni v1.0.0/go.mod h1:Meg73S6kFm/4PpbYdq35yYWoCZ9mS/YSx+lKnmiohz4=
github.com/vektah/gqlparser v1.1.2/go.mod h1:1ycwN7Ij5njmMkPPAOaRFY4rET2Enx7IkVv3vaXspKw= github.com/vektah/gqlparser v1.1.2/go.mod h1:1ycwN7Ij5njmMkPPAOaRFY4rET2Enx7IkVv3vaXspKw=
github.com/vishvananda/netlink v1.1.0/go.mod h1:cTgwzPIzzgDAYoQrMm0EdrjRUBkTqKYppBueQtXaqoE= github.com/vishvananda/netlink v1.1.0/go.mod h1:cTgwzPIzzgDAYoQrMm0EdrjRUBkTqKYppBueQtXaqoE=
...@@ -1440,6 +1445,7 @@ google.golang.org/api v0.36.0/go.mod h1:+z5ficQTmoYpPn8LCUNVpK5I7hwkpjbcgqA7I34q ...@@ -1440,6 +1445,7 @@ google.golang.org/api v0.36.0/go.mod h1:+z5ficQTmoYpPn8LCUNVpK5I7hwkpjbcgqA7I34q
google.golang.org/api v0.40.0 h1:uWrpz12dpVPn7cojP82mk02XDgTJLDPc2KbVTxrWb4A= google.golang.org/api v0.40.0 h1:uWrpz12dpVPn7cojP82mk02XDgTJLDPc2KbVTxrWb4A=
google.golang.org/api v0.40.0/go.mod h1:fYKFpnQN0DsDSKRVRcQSDQNtqWPfM9i+zNPxepjRCQ8= google.golang.org/api v0.40.0/go.mod h1:fYKFpnQN0DsDSKRVRcQSDQNtqWPfM9i+zNPxepjRCQ8=
google.golang.org/appengine v0.0.0-20160205025855-6a436539be38/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v0.0.0-20160205025855-6a436539be38/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
......
...@@ -26,7 +26,6 @@ ENV CATTLE_HELM_VERSION v2.16.8-rancher1 ...@@ -26,7 +26,6 @@ ENV CATTLE_HELM_VERSION v2.16.8-rancher1
ENV CATTLE_K3S_VERSION v1.19.8+k3s1 ENV CATTLE_K3S_VERSION v1.19.8+k3s1
ENV CATTLE_MACHINE_VERSION v0.15.0-rancher54 ENV CATTLE_MACHINE_VERSION v0.15.0-rancher54
ENV CATTLE_ETCD_VERSION v3.4.3 ENV CATTLE_ETCD_VERSION v3.4.3
ENV CATTLE_CHANNELSERVER_VERSION v0.5.0
ENV LOGLEVEL_VERSION v0.1.3 ENV LOGLEVEL_VERSION v0.1.3
ENV TINI_VERSION v0.18.0 ENV TINI_VERSION v0.18.0
ENV TELEMETRY_VERSION v0.5.14 ENV TELEMETRY_VERSION v0.5.14
...@@ -73,9 +72,6 @@ ENV HELM_URL_V2_amd64=https://github.com/rancher/helm/releases/download/${CATTLE ...@@ -73,9 +72,6 @@ ENV HELM_URL_V2_amd64=https://github.com/rancher/helm/releases/download/${CATTLE
K3S_URL_amd64=https://github.com/rancher/k3s/releases/download/${CATTLE_K3S_VERSION}/k3s \ K3S_URL_amd64=https://github.com/rancher/k3s/releases/download/${CATTLE_K3S_VERSION}/k3s \
K3S_URL_arm64=https://github.com/rancher/k3s/releases/download/${CATTLE_K3S_VERSION}/k3s-arm64 \ K3S_URL_arm64=https://github.com/rancher/k3s/releases/download/${CATTLE_K3S_VERSION}/k3s-arm64 \
K3S_URL=K3S_URL_${ARCH} \ K3S_URL=K3S_URL_${ARCH} \
CHANNELSERVER_URL_amd64=https://github.com/rancher/channelserver/releases/download/${CATTLE_CHANNELSERVER_VERSION}/channelserver-amd64 \
CHANNELSERVER_URL_arm64=https://github.com/rancher/channelserver/releases/download/${CATTLE_CHANNELSERVER_VERSION}/channelserver-arm64 \
CHANNELSERVER_URL=CHANNELSERVER_URL_${ARCH} \
ETCD_URL_amd64=https://github.com/etcd-io/etcd/releases/download/${CATTLE_ETCD_VERSION}/etcd-${CATTLE_ETCD_VERSION}-linux-amd64.tar.gz \ ETCD_URL_amd64=https://github.com/etcd-io/etcd/releases/download/${CATTLE_ETCD_VERSION}/etcd-${CATTLE_ETCD_VERSION}-linux-amd64.tar.gz \
ETCD_URL_arm64=https://github.com/etcd-io/etcd/releases/download/${CATTLE_ETCD_VERSION}/etcd-${CATTLE_ETCD_VERSION}-linux-arm64.tar.gz \ ETCD_URL_arm64=https://github.com/etcd-io/etcd/releases/download/${CATTLE_ETCD_VERSION}/etcd-${CATTLE_ETCD_VERSION}-linux-arm64.tar.gz \
ETCD_URL=ETCD_URL_${ARCH} \ ETCD_URL=ETCD_URL_${ARCH} \
...@@ -104,13 +100,12 @@ RUN curl ${HELM_URL_V3} | tar xvzf - --strip-components=1 -C /usr/bin && \ ...@@ -104,13 +100,12 @@ RUN curl ${HELM_URL_V3} | tar xvzf - --strip-components=1 -C /usr/bin && \
chmod +x /usr/bin/kustomize chmod +x /usr/bin/kustomize
RUN curl -sLf ${!TINI_URL} > /usr/bin/tini && \ RUN curl -sLf ${!TINI_URL} > /usr/bin/tini && \
curl -sLf ${!CHANNELSERVER_URL} > /usr/bin/channelserver && \
curl -sLf ${!K3S_URL} > /usr/bin/k3s && \ curl -sLf ${!K3S_URL} > /usr/bin/k3s && \
mkdir -p /var/lib/rancher/k3s/agent/images/ && \ mkdir -p /var/lib/rancher/k3s/agent/images/ && \
curl -sfL ${!ETCD_URL} | tar xvzf - --strip-components=1 -C /usr/bin/ etcd-${CATTLE_ETCD_VERSION}-linux-${ARCH}/etcd etcd-${CATTLE_ETCD_VERSION}-linux-${ARCH}/etcdctl && \ curl -sfL ${!ETCD_URL} | tar xvzf - --strip-components=1 -C /usr/bin/ etcd-${CATTLE_ETCD_VERSION}-linux-${ARCH}/etcd etcd-${CATTLE_ETCD_VERSION}-linux-${ARCH}/etcdctl && \
curl -sLf https://github.com/rancher/telemetry/releases/download/${TELEMETRY_VERSION}/telemetry-${ARCH} > /usr/bin/telemetry && \ curl -sLf https://github.com/rancher/telemetry/releases/download/${TELEMETRY_VERSION}/telemetry-${ARCH} > /usr/bin/telemetry && \
curl -sLf https://storage.googleapis.com/kubernetes-release/release/${KUBECTL_VERSION}/bin/linux/${ARCH}/kubectl > /usr/bin/kubectl && \ curl -sLf https://storage.googleapis.com/kubernetes-release/release/${KUBECTL_VERSION}/bin/linux/${ARCH}/kubectl > /usr/bin/kubectl && \
chmod +x /usr/bin/tini /usr/bin/telemetry /usr/bin/k3s /usr/bin/kubectl /usr/bin/channelserver && \ chmod +x /usr/bin/tini /usr/bin/telemetry /usr/bin/k3s /usr/bin/kubectl && \
mkdir -p /var/lib/rancher-data/driver-metadata mkdir -p /var/lib/rancher-data/driver-metadata
ENV CATTLE_UI_VERSION 2.5.2-rc8.1 ENV CATTLE_UI_VERSION 2.5.2-rc8.1
......
...@@ -13,7 +13,7 @@ require ( ...@@ -13,7 +13,7 @@ require (
github.com/rancher/gke-operator v1.0.1-rc6 github.com/rancher/gke-operator v1.0.1-rc6
github.com/rancher/norman v0.0.0-20210225010917-c7fd1e24145b github.com/rancher/norman v0.0.0-20210225010917-c7fd1e24145b
github.com/rancher/rke v1.3.0-rc1.0.20210218215557-dc70017c5941 github.com/rancher/rke v1.3.0-rc1.0.20210218215557-dc70017c5941
github.com/rancher/wrangler v0.7.3-0.20210407025123-cf9bb4f55cee github.com/rancher/wrangler v0.8.0
github.com/sirupsen/logrus v1.6.0 github.com/sirupsen/logrus v1.6.0
k8s.io/api v0.20.0 k8s.io/api v0.20.0
k8s.io/apimachinery v0.20.0 k8s.io/apimachinery v0.20.0
......
...@@ -517,8 +517,8 @@ github.com/rancher/lasso v0.0.0-20200427171700-e0509f89f319/go.mod h1:6Dw19z1lDI ...@@ -517,8 +517,8 @@ github.com/rancher/lasso v0.0.0-20200427171700-e0509f89f319/go.mod h1:6Dw19z1lDI
github.com/rancher/lasso v0.0.0-20200515155337-a34e1e26ad91/go.mod h1:G6Vv2aj6xB2YjTVagmu4NkhBvbE8nBcGykHRENH6arI= github.com/rancher/lasso v0.0.0-20200515155337-a34e1e26ad91/go.mod h1:G6Vv2aj6xB2YjTVagmu4NkhBvbE8nBcGykHRENH6arI=
github.com/rancher/lasso v0.0.0-20200820172840-0e4cc0ef5cb0/go.mod h1:OhBBBO1pBwYp0hacWdnvSGOj+XE9yMLOLnaypIlic18= github.com/rancher/lasso v0.0.0-20200820172840-0e4cc0ef5cb0/go.mod h1:OhBBBO1pBwYp0hacWdnvSGOj+XE9yMLOLnaypIlic18=
github.com/rancher/lasso v0.0.0-20200905045615-7fcb07d6a20b/go.mod h1:OhBBBO1pBwYp0hacWdnvSGOj+XE9yMLOLnaypIlic18= github.com/rancher/lasso v0.0.0-20200905045615-7fcb07d6a20b/go.mod h1:OhBBBO1pBwYp0hacWdnvSGOj+XE9yMLOLnaypIlic18=
github.com/rancher/lasso v0.0.0-20210407025055-18a00567c734 h1:zlGCVASfmlF3cICutcznNgtzR0xRTQOAzg6cPcS1o40= github.com/rancher/lasso v0.0.0-20210408231703-9ddd9378d08d h1:vfjPEF6M7Jf1/zK1xF7z2drLfniooKcgDQdoXO5+U7w=
github.com/rancher/lasso v0.0.0-20210407025055-18a00567c734/go.mod h1:OhBBBO1pBwYp0hacWdnvSGOj+XE9yMLOLnaypIlic18= github.com/rancher/lasso v0.0.0-20210408231703-9ddd9378d08d/go.mod h1:OhBBBO1pBwYp0hacWdnvSGOj+XE9yMLOLnaypIlic18=
github.com/rancher/norman v0.0.0-20200517050325-f53cae161640/go.mod h1:92rz/7QN7DOeLQZlJY/8aFBOmF085igIVguR0wpxLas= github.com/rancher/norman v0.0.0-20200517050325-f53cae161640/go.mod h1:92rz/7QN7DOeLQZlJY/8aFBOmF085igIVguR0wpxLas=
github.com/rancher/norman v0.0.0-20210225010917-c7fd1e24145b h1:4SV/mEqaGmwvAV5XIO+hRqacZR1KyW6sTqzFNIlyTAY= github.com/rancher/norman v0.0.0-20210225010917-c7fd1e24145b h1:4SV/mEqaGmwvAV5XIO+hRqacZR1KyW6sTqzFNIlyTAY=
github.com/rancher/norman v0.0.0-20210225010917-c7fd1e24145b/go.mod h1:hhnf77V2lmZD7cvUqi4vTBpIs3KpHNL/AmuN0MqEClI= github.com/rancher/norman v0.0.0-20210225010917-c7fd1e24145b/go.mod h1:hhnf77V2lmZD7cvUqi4vTBpIs3KpHNL/AmuN0MqEClI=
...@@ -528,8 +528,8 @@ github.com/rancher/wrangler v0.6.2-0.20200427172034-da9b142ae061/go.mod h1:n5Du/ ...@@ -528,8 +528,8 @@ github.com/rancher/wrangler v0.6.2-0.20200427172034-da9b142ae061/go.mod h1:n5Du/
github.com/rancher/wrangler v0.6.2-0.20200515155908-1923f3f8ec3f/go.mod h1:NmtmlLkchboIksYJuBemwcP4RBfv8FpeyhVoWXB9Wdc= github.com/rancher/wrangler v0.6.2-0.20200515155908-1923f3f8ec3f/go.mod h1:NmtmlLkchboIksYJuBemwcP4RBfv8FpeyhVoWXB9Wdc=
github.com/rancher/wrangler v0.6.2-0.20200820173016-2068de651106/go.mod h1:iKqQcYs4YSDjsme52OZtQU4jHPmLlIiM93aj2c8c/W8= github.com/rancher/wrangler v0.6.2-0.20200820173016-2068de651106/go.mod h1:iKqQcYs4YSDjsme52OZtQU4jHPmLlIiM93aj2c8c/W8=
github.com/rancher/wrangler v0.7.3-0.20201020003736-e86bc912dfac/go.mod h1:goezjesEKwMxHLfltdjg9DW0xWV7txQee6vOuSDqXAI= github.com/rancher/wrangler v0.7.3-0.20201020003736-e86bc912dfac/go.mod h1:goezjesEKwMxHLfltdjg9DW0xWV7txQee6vOuSDqXAI=
github.com/rancher/wrangler v0.7.3-0.20210407025123-cf9bb4f55cee h1:xSaIJ8MRj7wgcYSRaTBDiC90jIyOl3+LUMAshNIWozg= github.com/rancher/wrangler v0.8.0 h1:jGWr7ES0KwZU/8zB6lte0z4QB7hFcspaXPTvGmrvHok=
github.com/rancher/wrangler v0.7.3-0.20210407025123-cf9bb4f55cee/go.mod h1:JJ68YG6bgMGArlEZrrif9gwIJEtGsk44g51Eovael9E= github.com/rancher/wrangler v0.8.0/go.mod h1:zSV5oh3+YZboilwcJmFHO3J6FZba82BTQft1b6ijx2I=
github.com/rancher/wrangler-api v0.6.1-0.20200427172631-a7c2f09b783e/go.mod h1:2lcWR98q8HU3U4mVETnXc8quNG0uXxrt8vKd6cAa/30= github.com/rancher/wrangler-api v0.6.1-0.20200427172631-a7c2f09b783e/go.mod h1:2lcWR98q8HU3U4mVETnXc8quNG0uXxrt8vKd6cAa/30=
github.com/remyoudompheng/bigfft v0.0.0-20170806203942-52369c62f446/go.mod h1:uYEyJGbgTkfkS4+E/PavXkNJcbFIpEtjt2B0KDQ5+9M= github.com/remyoudompheng/bigfft v0.0.0-20170806203942-52369c62f446/go.mod h1:uYEyJGbgTkfkS4+E/PavXkNJcbFIpEtjt2B0KDQ5+9M=
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
......
...@@ -3,30 +3,23 @@ ...@@ -3,30 +3,23 @@
import ( import (
"context" "context"
"encoding/json" "encoding/json"
"os" "net/http"
"os/exec"
"strconv" "strconv"
"strings"
"time" "time"
"github.com/rancher/channelserver/pkg/config"
"github.com/rancher/channelserver/pkg/server"
"github.com/rancher/rancher/pkg/catalog/utils" "github.com/rancher/rancher/pkg/catalog/utils"
"github.com/rancher/rancher/pkg/settings" "github.com/rancher/rancher/pkg/settings"
"github.com/rancher/wrangler/pkg/data" "github.com/rancher/wrangler/pkg/data"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"k8s.io/client-go/util/flowcontrol"
) )
var ( func GetURLAndInterval() (string, time.Duration) {
prog = "channelserver"
channelserverCmd *exec.Cmd
backoff = flowcontrol.NewBackOff(5*time.Second, 15*time.Minute)
)
func GetURLAndInterval() (string, string) {
val := map[string]interface{}{} val := map[string]interface{}{}
if err := json.Unmarshal([]byte(settings.RkeMetadataConfig.Get()), &val); err != nil { if err := json.Unmarshal([]byte(settings.RkeMetadataConfig.Get()), &val); err != nil {
logrus.Errorf("failed to parse %s value: %v", settings.RkeMetadataConfig.Name, err) logrus.Errorf("failed to parse %s value: %v", settings.RkeMetadataConfig.Name, err)
return "", "" return "", 0
} }
url := data.Object(val).String("url") url := data.Object(val).String("url")
minutes, _ := strconv.Atoi(data.Object(val).String("refresh-interval-minutes")) minutes, _ := strconv.Atoi(data.Object(val).String("refresh-interval-minutes"))
...@@ -34,75 +27,53 @@ func GetURLAndInterval() (string, string) { ...@@ -34,75 +27,53 @@ func GetURLAndInterval() (string, string) {
minutes = 1440 minutes = 1440
} }
return url, (time.Duration(minutes) * time.Minute).String() return url, time.Duration(minutes) * time.Minute
} }
func run(cmdArgs []string) chan error { // getChannelServerArg will return with an argument to pass to channel server
done := make(chan error, 1) // to indicate the server version that is running. If the current version is
go func() { // not a proper release version, the argument will be empty.
defer close(done) func getChannelServerArg() string {
url, interval := GetURLAndInterval() serverVersion := settings.ServerVersion.Get()
cmdArgs = append(cmdArgs, "--url", url, if !utils.ReleaseServerVersion(serverVersion) {
"--url=/var/lib/rancher-data/driver-metadata/data.json", return ""
"--refresh-interval", interval, }
"--channel-server-version", getChannelServerArg(), getChannelServerArg()) return serverVersion
cmd := exec.Command(prog, cmdArgs...)
channelserverCmd = cmd
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
done <- cmd.Run()
}()
return done
} }
func Start(ctx context.Context, cmdArgs []string) error { type DynamicInterval struct{}
if _, err := exec.LookPath(prog); err != nil {
logrus.Errorf("Failed to find %s, will not run /v1-release API: %v", prog, err)
return nil
}
func (d *DynamicInterval) Wait(ctx context.Context) bool {
start := time.Now()
for { for {
select { select {
case <-ctx.Done(): case <-time.After(time.Second):
if err := Shutdown(); err != nil { _, duration := GetURLAndInterval()
logrus.Errorf("error terminating channelserver: %v", err) if start.Add(duration).Before(time.Now()) {
return true
} }
return ctx.Err() continue
case err := <-run(cmdArgs):
logrus.Infof("failed to run channelserver: %v", err)
}
backoff.Next("next", time.Now())
select {
case <-time.After(backoff.Get("next")):
case <-ctx.Done(): case <-ctx.Done():
return ctx.Err() return false
} }
} }
} }
// getChannelServerArg will return with an argument to pass to channel server type DynamicSource struct{}
// to indicate the server version that is running. If the current version is
// not a proper release version, the argument will be empty. func (d *DynamicSource) URL() string {
func getChannelServerArg() string { url, _ := GetURLAndInterval()
serverVersion := settings.ServerVersion.Get() return url
if !utils.ReleaseServerVersion(serverVersion) {
return ""
}
return serverVersion
} }
// Shutdown ends the channelserver process and resets backoff func NewHandler(ctx context.Context) http.Handler {
func Shutdown() error { interval := &DynamicInterval{}
backoff.Reset("next") urls := []config.Source{
if channelserverCmd == nil { &DynamicSource{},
return nil config.StringSource("/var/lib/rancher-data/driver-metadata/data.json"),
}
if err := channelserverCmd.Process.Kill(); err != nil {
if !strings.Contains(err.Error(), "process already finished") {
return err
}
} }
channelserverCmd = nil return server.NewHandler(map[string]*config.Config{
return nil "v1-k3s-release": config.NewConfig(ctx, "k3s", interval, getChannelServerArg(), urls),
"v1-rke2-release": config.NewConfig(ctx, "rke2", interval, getChannelServerArg(), urls),
})
} }
package channelserver
import (
"context"
"net/http/httputil"
rurl "net/url"
)
func NewProxy(ctx context.Context) *httputil.ReverseProxy {
const rawURL = "http://localhost:8115"
cmdArgs := []string{"--config-key=k3s",
"--config-key=rke2",
"--path-prefix=v1-k3s-release",
"--path-prefix=v1-rke2-release",
"--listen-address=0.0.0.0:8115"}
go Start(ctx, cmdArgs)
url, _ := rurl.Parse(rawURL)
return httputil.NewSingleHostReverseProxy(url)
}
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
podsecuritypolicy2 "github.com/rancher/rancher/pkg/controllers/management/podsecuritypolicy" podsecuritypolicy2 "github.com/rancher/rancher/pkg/controllers/management/podsecuritypolicy"
"github.com/rancher/rancher/pkg/controllers/managementapi/catalog" "github.com/rancher/rancher/pkg/controllers/managementapi/catalog"
"github.com/rancher/rancher/pkg/controllers/managementapi/dynamicschema" "github.com/rancher/rancher/pkg/controllers/managementapi/dynamicschema"
"github.com/rancher/rancher/pkg/controllers/managementapi/k3smetadata"
"github.com/rancher/rancher/pkg/controllers/managementapi/samlconfig" "github.com/rancher/rancher/pkg/controllers/managementapi/samlconfig"
"github.com/rancher/rancher/pkg/controllers/managementapi/usercontrollers" "github.com/rancher/rancher/pkg/controllers/managementapi/usercontrollers"
whitelistproxyKontainerDriver "github.com/rancher/rancher/pkg/controllers/managementapi/whitelistproxy/kontainerdriver" whitelistproxyKontainerDriver "github.com/rancher/rancher/pkg/controllers/managementapi/whitelistproxy/kontainerdriver"
...@@ -35,7 +34,6 @@ func Register(ctx context.Context, scaledContext *config.ScaledContext, clusterM ...@@ -35,7 +34,6 @@ func Register(ctx context.Context, scaledContext *config.ScaledContext, clusterM
whitelistproxyNodeDriver.Register(ctx, scaledContext) whitelistproxyNodeDriver.Register(ctx, scaledContext)
whitelistproxyKontainerDriver.Register(ctx, scaledContext) whitelistproxyKontainerDriver.Register(ctx, scaledContext)
samlconfig.Register(ctx, scaledContext) samlconfig.Register(ctx, scaledContext)
k3smetadata.Register(ctx, scaledContext)
usercontrollers.Register(ctx, scaledContext, clusterManager) usercontrollers.Register(ctx, scaledContext, clusterManager)
return nil return nil
} }
......
package k3smetadata
import (
"context"
"encoding/json"
"fmt"
"strconv"
"time"
"github.com/rancher/rancher/pkg/channelserver"
v3 "github.com/rancher/rancher/pkg/generated/norman/management.cattle.io/v3"
"github.com/rancher/rancher/pkg/settings"
"github.com/rancher/rancher/pkg/types/config"
"github.com/rancher/wrangler/pkg/data"
"k8s.io/apimachinery/pkg/runtime"
)
const (
forceRefreshAnnotation = "field.cattle.io/lastForceRefresh"
)
type handler struct {
url string
interval string
lastForceReresh string
ctx context.Context
}
func Register(ctx context.Context, scaled *config.ScaledContext) {
url, interval := channelserver.GetURLAndInterval()
h := &handler{
url: url,
interval: interval,
ctx: ctx,
}
scaled.Management.Settings("").AddHandler(ctx, "channelserver-restart-handler", h.sync)
}
func (h *handler) sync(key string, setting *v3.Setting) (runtime.Object, error) {
if setting == nil || setting.DeletionTimestamp != nil {
return nil, nil
}
if setting.Name != settings.RkeMetadataConfig.Name {
return setting, nil
}
val := map[string]interface{}{}
metadataConfig := setting.Default
if setting.Value != "" {
metadataConfig = setting.Value
}
if err := json.Unmarshal([]byte(metadataConfig), &val); err != nil {
return setting, err
}
updatedURL := data.Object(val).String("url")
updatedIntervalMinutes, _ := strconv.Atoi(data.Object(val).String("refresh-interval-minutes"))
if updatedIntervalMinutes == 0 {
updatedIntervalMinutes = 1440
}
updatedInterval := (time.Duration(updatedIntervalMinutes) * time.Minute).String()
updatedForceRefresh, _ := setting.Annotations[forceRefreshAnnotation]
noEffectiveChanges := h.url == updatedURL && h.interval == updatedInterval && h.lastForceReresh == updatedForceRefresh
if noEffectiveChanges {
return setting, nil
}
persistedURL, persistedInterval := channelserver.GetURLAndInterval()
if persistedURL != updatedURL && persistedInterval != updatedInterval {
// channelserver Start() uses the cache and will pass incorrect values if started now
return setting, fmt.Errorf("rke metadata cache has not been updated yet")
}
if err := channelserver.Shutdown(); err != nil {
return setting, err
}
h.url = updatedURL
h.interval = updatedInterval
h.lastForceReresh = updatedForceRefresh
return setting, nil
}
...@@ -86,7 +86,7 @@ func router(ctx context.Context, localClusterEnabled bool, tunnelAuthorizer *mcm ...@@ -86,7 +86,7 @@ func router(ctx context.Context, localClusterEnabled bool, tunnelAuthorizer *mcm
if features.Legacy.Enabled() { if features.Legacy.Enabled() {
unauthed.PathPrefix("/hooks").Handler(hooks.New(scaledContext)) unauthed.PathPrefix("/hooks").Handler(hooks.New(scaledContext))
} }
unauthed.PathPrefix("/v1-{prefix}-release/release").Handler(channelserver.NewProxy(ctx)) unauthed.PathPrefix("/v1-{prefix}-release/release").Handler(channelserver.NewHandler(ctx))
unauthed.PathPrefix("/v1-saml").Handler(saml.AuthHandler()) unauthed.PathPrefix("/v1-saml").Handler(saml.AuthHandler())
unauthed.PathPrefix("/v3-public").Handler(publicAPI) unauthed.PathPrefix("/v3-public").Handler(publicAPI)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册