Commit Graph

43 Commits

Author SHA1 Message Date
Davanum Srinivas
a88dc632a4
kube-apiserver: default --enable-logs-handler flag to false
Co-Authored-By: Iceber Gu <wei.cai-nat@daocloud.io>
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2024-06-28 15:22:22 -04:00
Jefftree
c771c6b526 Update aggregated discovery to v2 fixture 2024-03-12 13:29:14 -04:00
Antonio Ojea
727d127e6f don´t run openapi spec with ConsistentListFromCache feature gate enabled
Change-Id: I959a5df6259a358db2232733b386afc274b021bd
2024-03-11 21:45:02 +00:00
Tim Hockin
8288c06b2b
Make hack scripts use go install and assume PATH
Now that they all call setup_env, we don't need find-binary (I think).
That was originally meant to hide the diff between docker and local
builds but all these tools do local builds anyway.
2024-02-29 22:07:32 -08:00
Tim Hockin
530c4352fb
Rename new::setup_env back to setup_env 2024-02-29 22:06:44 -08:00
Tim Hockin
974276e4a0
Change update-openapi-spec to new setup_env 2024-02-29 22:06:03 -08:00
Tim Hockin
5f490b4fe8
Clarify, document KUBE_OUTPUT_* variables 2024-02-29 22:05:42 -08:00
Tim Hockin
8b579b2347
Change the build_binaries path to use modules
This makes "new" and "old" setup_env functions. In subsequent commits,
all callers of the "old" form will be fixed, and the "new" will be
renamed back.

The old and new functions diff:

```diff
--- /tmp/a	2023-12-14 09:02:57.804092696 -0800
+++ /tmp/b	2023-12-14 09:03:09.679999585 -0800
@@ -1,4 +1,4 @@
-kube::golang::old::setup_env() {
+kube::golang:🆕:setup_env() {
   kube::golang::verify_go_version

   # Set up GOPATH.  We have tools which depend on being in a GOPATH (see
@@ -7,9 +7,9 @@
   # Even in module mode, we need to set GOPATH for `go build` and `go install`
   # to work.  We build various tools (usually via `go install`) from a lot of
   # scripts.
-  #   * We can't set GOBIN because that does not work on cross-compiles.
-  #   * We could use `go build -o <something>`, but it's subtle when it comes
-  #     to cross-compiles and whether the <something> is a file or a directory,
+  #   * We can't just set GOBIN because that does not work on cross-compiles.
+  #   * We could always use `go build -o <something>`, but it's subtle wrt
+  #     cross-compiles and whether the <something> is a file or a directory,
   #     and EVERY caller has to get it *just* right.
   #   * We could leave GOPATH alone and let `go install` write binaries
   #     wherever the user's GOPATH says (or doesn't say).
@@ -20,16 +20,6 @@
   #
   # Eventually, when we no longer rely on run-in-gopath.sh we may be able to
   # simplify this some.
-  local go_pkg_dir="${KUBE_GOPATH}/src/${KUBE_GO_PACKAGE}"
-  local go_pkg_basedir
-  go_pkg_basedir=$(dirname "${go_pkg_dir}")
-
-  mkdir -p "${go_pkg_basedir}"
-
-  # TODO: This symlink should be relative.
-  if [[ ! -e "${go_pkg_dir}" || "$(readlink "${go_pkg_dir}")" != "${KUBE_ROOT}" ]]; then
-    ln -snf "${KUBE_ROOT}" "${go_pkg_dir}"
-  fi
   export GOPATH="${KUBE_GOPATH}"

   # If these are not set, set them now.  This ensures that any subsequent
@@ -40,24 +30,10 @@
   # Make sure our own Go binaries are in PATH.
   export PATH="${KUBE_GOPATH}/bin:${PATH}"

-  # Change directories so that we are within the GOPATH.  Some tools get really
-  # upset if this is not true.  We use a whole fake GOPATH here to collect the
-  # resultant binaries.
-  local subdir
-  subdir=$(kube::realpath . | sed "s|${KUBE_ROOT}||")
-  cd "${KUBE_GOPATH}/src/${KUBE_GO_PACKAGE}/${subdir}" || return 1
-
-  # Set GOROOT so binaries that parse code can work properly.
-  GOROOT=$(go env GOROOT)
-  export GOROOT
-
   # Unset GOBIN in case it already exists in the current session.
   # Cross-compiles will not work with it set.
   unset GOBIN

-  # This seems to matter to some tools
-  export GO15VENDOREXPERIMENT=1
-
-  # Disable workspaces
-  export GOWORK=off
+  # Explicitly turn on modules.
+  export GO111MODULE=on
 }
```

Result: `make` works for k/k:

```
$ make kubectl
+++ [1211 11:07:31] Building go targets for linux/amd64
    k8s.io/kubernetes/cmd/kubectl (static)

$ make WHAT=./cmd/kubectl/
+++ [1211 11:08:19] Building go targets for linux/amd64
    k8s.io/kubernetes/./cmd/kubectl/ (non-static)

$ make WHAT=k8s.io/kubernetes/cmd/kubectl
+++ [1211 11:08:52] Building go targets for linux/amd64
    k8s.io/kubernetes/cmd/kubectl (static)
```

Result: `make` works for staging by package:

```
$ make WHAT=k8s.io/api
+++ [1211 11:11:37] Building go targets for linux/amd64
    k8s.io/api (non-static)
```

Result: `make` fails for staging by path:

```
$ make WHAT=./staging/src/k8s.io/api
+++ [1211 11:12:44] Building go targets for linux/amd64
    k8s.io/kubernetes/./staging/src/k8s.io/api (non-static)
cannot find module providing package k8s.io/kubernetes/staging/src/k8s.io/api: import lookup disabled by -mod=vendor
	(Go version in go.work is at least 1.14 and vendor directory exists.)
!!! [1211 11:12:44] Call tree:
!!! [1211 11:12:44]  1: /home/thockin/src/kubernetes/hack/lib/golang.sh:850 kube::golang::build_some_binaries(...)
!!! [1211 11:12:44]  2: /home/thockin/src/kubernetes/hack/lib/golang.sh:1012 kube::golang::build_binaries_for_platform(...)
!!! [1211 11:12:44]  3: hack/make-rules/build.sh:27 kube::golang::build_binaries(...)
!!! [1211 11:12:44] Call tree:
!!! [1211 11:12:44]  1: hack/make-rules/build.sh:27 kube::golang::build_binaries(...)
!!! [1211 11:12:44] Call tree:
!!! [1211 11:12:44]  1: hack/make-rules/build.sh:27 kube::golang::build_binaries(...)
make: *** [Makefile:96: all] Error 1
```

Result: `make test` fails:

```
$ make test WHAT=./cmd/kubectl
+++ [1211 11:13:38] Set GOMAXPROCS automatically to 6
+++ [1211 11:13:38] Running tests without code coverage and with -race
cmd/kubectl/kubectl.go:25:2: cannot find package "k8s.io/client-go/plugin/pkg/client/auth" in any of:
	/home/thockin/src/kubernetes/_output/local/go/src/k8s.io/kubernetes/vendor/k8s.io/client-go/plugin/pkg/client/auth (vendor tree)
	/home/thockin/sdk/gotip/src/k8s.io/client-go/plugin/pkg/client/auth (from $GOROOT)
	/home/thockin/src/kubernetes/_output/local/go/src/k8s.io/client-go/plugin/pkg/client/auth (from $GOPATH)
cmd/kubectl/kubectl.go:20:2: cannot find package "k8s.io/component-base/cli" in any of:
	/home/thockin/src/kubernetes/_output/local/go/src/k8s.io/kubernetes/vendor/k8s.io/component-base/cli (vendor tree)
	/home/thockin/sdk/gotip/src/k8s.io/component-base/cli (from $GOROOT)
	/home/thockin/src/kubernetes/_output/local/go/src/k8s.io/component-base/cli (from $GOPATH)
cmd/kubectl/kubectl.go:21:2: cannot find package "k8s.io/kubectl/pkg/cmd" in any of:
	/home/thockin/src/kubernetes/_output/local/go/src/k8s.io/kubernetes/vendor/k8s.io/kubectl/pkg/cmd (vendor tree)
	/home/thockin/sdk/gotip/src/k8s.io/kubectl/pkg/cmd (from $GOROOT)
	/home/thockin/src/kubernetes/_output/local/go/src/k8s.io/kubectl/pkg/cmd (from $GOPATH)
cmd/kubectl/kubectl.go:22:2: cannot find package "k8s.io/kubectl/pkg/cmd/util" in any of:
	/home/thockin/src/kubernetes/_output/local/go/src/k8s.io/kubernetes/vendor/k8s.io/kubectl/pkg/cmd/util (vendor tree)
	/home/thockin/sdk/gotip/src/k8s.io/kubectl/pkg/cmd/util (from $GOROOT)
	/home/thockin/src/kubernetes/_output/local/go/src/k8s.io/kubectl/pkg/cmd/util (from $GOPATH)
make: *** [Makefile:191: test] Error 1
```
2024-02-29 00:22:07 -08:00
Benjamin Elder
3c530eea2d automatically setup etcd when running verify/update openapi-spec.sh
1. automatically add etcd to current PATH when calling kube::etcd::install

2. call kube::etcd::install from update-openapi-spec

3. don't call kube::golang::setup_env twice
2023-10-25 11:22:45 -07:00
Jordan Liggitt
2ab6fd3590
Capture discovery API output in test fixtures 2023-05-15 14:18:18 -04:00
Tim Hockin
597d52ac10
Remove openapi files before regen 2023-01-21 17:46:22 -08:00
Richard Kovacs
17422ff5c1
Use proper tmp directory for update-openapi-spec.sh (#115106)
* Use proper tmp directory for update-openapi-spec.sh

* Use proper mktmp command in update-openapi-specs.sh
2023-01-18 16:06:33 -08:00
Patrick Ohly
41619ace15 stop using deprecated klog flags
Some scripts and tools still relied on the deprecated flags, the ones
which are about to be removed.

This is intentionally not a complete removal of all those flags in the entire
repo. This would lead to much more code churn also in places where commands
still accept the flags because they use klog directly.
2022-09-04 21:02:43 +02:00
Jordan Liggitt
ddd15e1d8c omit enums from static openapi snapshots used to generate clients 2022-03-31 12:31:47 -04:00
Alex Zielenski
11b3a18cca
Update kube-openapi (#108895)
* upgrade k8s.io/kube-openapi

* fix open-api v3 blank aggregator output

* use keys as API group

in ./hack/update-openapi-spec.sh

* fix import grouping

* update openapiv3 integration tests
2022-03-24 14:01:01 -07:00
Sergey Kanzhelev
0d79a5f20c support removal of files by the ./hack/update-openapi-spec.sh 2021-12-16 18:47:56 +00:00
Jordan Liggitt
f30c5738ea Unversion and normalize openapi v3 fixtures 2021-11-24 10:03:36 -05:00
Jefftree
ae1984a89d Generate openapi v3 static files 2021-11-16 17:38:54 -08:00
Qiming Teng
e1ec14162f Fix OpenAPI spec generator script 2020-12-14 10:10:33 +08:00
knight42
00e4234cc9
fix: pass bearer token to curl using -H instead of --oauth2-bearer
The flag `--oauth2-bearer` might have no effect in some environment.

Signed-off-by: knight42 <anonymousknight96@gmail.com>
2020-11-05 01:15:19 +08:00
Shihang Zhang
ff641f6eb2 mv TokenRequest and TokenRequestProjection to GA 2020-10-29 20:47:01 -07:00
knight42
cfc2b330a7
refactor(apiserver): ignore the insecure flags
Leave the insecure flags intact but stop serving on insecure port.
2020-10-29 23:20:17 +08:00
Kubernetes Prow Robot
79bb357193
Merge pull request #84654 from liggitt/drop-openapi-version
Drop version from static openapi json file
2020-01-08 11:59:39 -08:00
RainbowMango
12d08d52ee Improve output of update-openapi-spec.sh when printing logs from file. 2019-12-27 09:22:16 +08:00
Jordan Liggitt
18ba6f9482 Remove references to unserved types 2019-12-13 12:21:33 -05:00
Jordan Liggitt
b44d7c8d3c Drop version from static openapi json file 2019-11-01 13:35:10 -04:00
Mike Danese
b9c7007ca0 enable token review when openapi is generated 2019-07-09 13:45:41 -07:00
SataQiu
142e458a97 fix shellcheck failures of hack/update-openapi-spec.sh 2019-04-16 03:40:56 +08:00
Dr. Stefan Schimanski
2393799e2e hack/update-openapi-spec.sh: normalize indention of spec through jq 2019-02-11 13:16:36 +01:00
Jordan Liggitt
b64075dbd0 explicitly enable apps/v1beta1, apps/v1beta2, extensions/v1beta1 for print,etcd,storage tests 2019-01-24 21:43:15 -05:00
Kubernetes Prow Robot
31311a6343
Merge pull request #73148 from liggitt/remove-deprecated-swagger-paths
remove deprecated openapi paths in favor of /openapi/v2
2019-01-23 22:06:21 -08:00
Jordan Liggitt
52519ecb1c remove deprecated openapi paths in favor of /openapi/v2 2019-01-21 16:33:41 -05:00
Roy Lenferink
6df3deb4bc Bash script syntax improvements 2019-01-19 13:58:58 +01:00
Cao Shufeng
7b1ba187f7 remove unused variable in openapi-spec script 2018-06-29 13:45:17 +08:00
Antoine Pelisse
0685a8018e Print error when APIServer fails to start 2018-06-27 09:59:41 -07:00
Kubernetes Submit Queue
31511f9e24
Merge pull request #63383 from liggitt/lease-reconciler
Automatic merge from submit-queue (batch tested with PRs 63315, 63383, 63318, 63439). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

Re-enable lease reconciler, fix shutdown race

Fixes #63378
Fixes #57617

* Fixes the openapi script to wait for the apiserver on shutdown (like all the other scripts do)
* Fixes the apiserver shutdown to not hang forever if the kubernetes service reconciler cannot persist to etcd
* Readds https://github.com/kubernetes/kubernetes/pull/58474 to make the default the lease reconciler

```release-note
kube-apiserver: the default `--endpoint-reconciler-type` is now `lease`. The `master-count` endpoint reconciler type is deprecated and will be removed in 1.13.
```
2018-05-04 12:41:09 -07:00
Jordan Liggitt
30f2962ede
Make openapi spec generation wait for the apiserver on shutdown 2018-05-02 22:44:48 -04:00
Matthias Bertschy
9b15af19b2 Update all script to use /usr/bin/env bash in shebang 2018-04-19 13:20:13 +02:00
Tim Hockin
0777ecd030 Fix race in service IP allocation repair loop 2016-12-26 21:59:27 -08:00
mbohlool
6e2eba5399 Update OpenAPI spec generator to enable all APIs 2016-11-11 16:29:49 -08:00
mbohlool
75451b49f4 - Add GroupVersion as tags to OpenAPI spec
- Remove all end-point specs as they are not useful in light of GroupVersion tags in main spec
2016-10-25 14:27:48 -07:00
mbohlool
3e67cf8b9b Add authentication to openapi Spec 2016-10-22 02:43:42 -07:00
mbohlool
35b5174bf1 Generate and verify openapi specs in source tree at api/openapi-spec 2016-09-29 17:03:31 -07:00