Add CRI v1 proto
Add CRI v1 proto and generated code. We need both v1 and v1alpha2 side by side so that containerd and CRI-O could be updated. Once the runtimes are updated and in the CI, we can switch the kubelet to use v1 in 1.21 . We are jumping to v1, so we have to avoid multiple hops to get to GA. The package could stay v1 and declare CRI support to be at beta and eventually GA. Signed-off-by: Mrunal Patel <mpatel@redhat.com>
This commit is contained in:
parent
1d4c0ad6f3
commit
9fcede9d5b
@ -22,9 +22,11 @@ set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
|
||||
KUBE_REMOTE_RUNTIME_ROOT="${KUBE_ROOT}/staging/src/k8s.io/cri-api/pkg/apis/runtime/v1alpha2"
|
||||
KUBE_REMOTE_RUNTIME_ROOT="${KUBE_ROOT}/staging/src/k8s.io/cri-api/pkg/apis/runtime/"
|
||||
source "${KUBE_ROOT}/hack/lib/init.sh"
|
||||
|
||||
runtime_versions=("v1alpha2" "v1")
|
||||
|
||||
kube::golang::setup_env
|
||||
|
||||
go install k8s.io/kubernetes/vendor/k8s.io/code-generator/cmd/go-to-protobuf/protoc-gen-gogo
|
||||
@ -40,24 +42,34 @@ if [[ -z "$(which protoc)" || "$(protoc --version)" != "libprotoc 3."* ]]; then
|
||||
fi
|
||||
|
||||
function cleanup {
|
||||
rm -f "${KUBE_REMOTE_RUNTIME_ROOT}/api.pb.go.bak"
|
||||
rm -f "${KUBE_REMOTE_RUNTIME_ROOT}/api.pb.go.tmp"
|
||||
for v in "${runtime_versions[@]}"; do
|
||||
rm -f "${KUBE_REMOTE_RUNTIME_ROOT}/${v}/api.pb.go.bak"
|
||||
rm -f "${KUBE_REMOTE_RUNTIME_ROOT}/${v}/api.pb.go.tmp"
|
||||
done
|
||||
}
|
||||
|
||||
trap cleanup EXIT
|
||||
|
||||
gogopath=$(dirname "$(kube::util::find-binary "protoc-gen-gogo")")
|
||||
PATH="${gogopath}:${PATH}"
|
||||
|
||||
PATH="${gogopath}:${PATH}" \
|
||||
protoc \
|
||||
--proto_path="${KUBE_REMOTE_RUNTIME_ROOT}" \
|
||||
--proto_path="${KUBE_ROOT}/vendor" \
|
||||
--gogo_out=plugins=grpc:"${KUBE_REMOTE_RUNTIME_ROOT}" "${KUBE_REMOTE_RUNTIME_ROOT}/api.proto"
|
||||
function generate_code() {
|
||||
RUNTIME_API_VERSION="$1"
|
||||
KUBE_REMOTE_RUNTIME_PATH="${KUBE_REMOTE_RUNTIME_ROOT}/${RUNTIME_API_VERSION}"
|
||||
protoc \
|
||||
--proto_path="${KUBE_REMOTE_RUNTIME_PATH}" \
|
||||
--proto_path="${KUBE_ROOT}/vendor" \
|
||||
--gogo_out=plugins=grpc:"${KUBE_REMOTE_RUNTIME_PATH}" "${KUBE_REMOTE_RUNTIME_PATH}/api.proto"
|
||||
|
||||
# Update boilerplate for the generated file.
|
||||
cat hack/boilerplate/boilerplate.generatego.txt "${KUBE_REMOTE_RUNTIME_ROOT}/api.pb.go" > "${KUBE_REMOTE_RUNTIME_ROOT}/api.pb.go.tmp"
|
||||
mv "${KUBE_REMOTE_RUNTIME_ROOT}/api.pb.go.tmp" "${KUBE_REMOTE_RUNTIME_ROOT}/api.pb.go"
|
||||
# Update boilerplate for the generated file.
|
||||
cat hack/boilerplate/boilerplate.generatego.txt "${KUBE_REMOTE_RUNTIME_PATH}/api.pb.go" > "${KUBE_REMOTE_RUNTIME_PATH}/api.pb.go.tmp"
|
||||
mv "${KUBE_REMOTE_RUNTIME_PATH}/api.pb.go.tmp" "${KUBE_REMOTE_RUNTIME_PATH}/api.pb.go"
|
||||
|
||||
# Run gofmt to clean up the generated code.
|
||||
kube::golang::verify_go_version
|
||||
gofmt -l -s -w "${KUBE_REMOTE_RUNTIME_ROOT}/api.pb.go"
|
||||
# Run gofmt to clean up the generated code.
|
||||
kube::golang::verify_go_version
|
||||
gofmt -l -s -w "${KUBE_REMOTE_RUNTIME_PATH}/api.pb.go"
|
||||
}
|
||||
|
||||
for v in "${runtime_versions[@]}"; do
|
||||
generate_code "${v}"
|
||||
done
|
||||
|
@ -24,27 +24,39 @@ set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
|
||||
KUBE_REMOTE_RUNTIME_ROOT="${KUBE_ROOT}/staging/src/k8s.io/cri-api/pkg/apis/runtime/v1alpha2"
|
||||
KUBE_REMOTE_RUNTIME_ROOT="${KUBE_ROOT}/staging/src/k8s.io/cri-api/pkg/apis/runtime/"
|
||||
source "${KUBE_ROOT}/hack/lib/init.sh"
|
||||
|
||||
runtime_versions=("v1alpha2" "v1")
|
||||
|
||||
kube::golang::setup_env
|
||||
|
||||
function cleanup {
|
||||
rm -rf "${KUBE_REMOTE_RUNTIME_ROOT}/_tmp/"
|
||||
for v in "${runtime_versions[@]}"; do
|
||||
rm -rf "${KUBE_REMOTE_RUNTIME_ROOT}/${v}/_tmp/"
|
||||
done
|
||||
}
|
||||
|
||||
trap cleanup EXIT
|
||||
|
||||
mkdir -p "${KUBE_REMOTE_RUNTIME_ROOT}/_tmp"
|
||||
cp "${KUBE_REMOTE_RUNTIME_ROOT}/api.pb.go" "${KUBE_REMOTE_RUNTIME_ROOT}/_tmp/"
|
||||
function verify_generated_code() {
|
||||
RUNTIME_API_VERSION="$1"
|
||||
KUBE_REMOTE_RUNTIME_PATH="${KUBE_REMOTE_RUNTIME_ROOT}/${RUNTIME_API_VERSION}"
|
||||
mkdir -p "${KUBE_REMOTE_RUNTIME_PATH}/_tmp"
|
||||
cp "${KUBE_REMOTE_RUNTIME_PATH}/api.pb.go" "${KUBE_REMOTE_RUNTIME_PATH}/_tmp/"
|
||||
|
||||
ret=0
|
||||
KUBE_VERBOSE=3 "${KUBE_ROOT}/hack/update-generated-runtime.sh"
|
||||
diff -I "gzipped FileDescriptorProto" -I "0x" -Naupr "${KUBE_REMOTE_RUNTIME_ROOT}/_tmp/api.pb.go" "${KUBE_REMOTE_RUNTIME_ROOT}/api.pb.go" || ret=$?
|
||||
if [[ $ret -eq 0 ]]; then
|
||||
echo "Generated container runtime api is up to date."
|
||||
cp "${KUBE_REMOTE_RUNTIME_ROOT}/_tmp/api.pb.go" "${KUBE_REMOTE_RUNTIME_ROOT}/"
|
||||
else
|
||||
echo "Generated container runtime api is out of date. Please run hack/update-generated-runtime.sh"
|
||||
exit 1
|
||||
fi
|
||||
ret=0
|
||||
KUBE_VERBOSE=3 "${KUBE_ROOT}/hack/update-generated-runtime.sh"
|
||||
diff -I "gzipped FileDescriptorProto" -I "0x" -Naupr "${KUBE_REMOTE_RUNTIME_PATH}/_tmp/api.pb.go" "${KUBE_REMOTE_RUNTIME_PATH}/api.pb.go" || ret=$?
|
||||
if [[ $ret -eq 0 ]]; then
|
||||
echo "Generated container runtime api is up to date."
|
||||
cp "${KUBE_REMOTE_RUNTIME_PATH}/_tmp/api.pb.go" "${KUBE_REMOTE_RUNTIME_PATH}/"
|
||||
else
|
||||
echo "Generated container runtime api is out of date. Please run hack/update-generated-runtime.sh"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
for v in "${runtime_versions[@]}"; do
|
||||
verify_generated_code "${v}"
|
||||
done
|
||||
|
@ -20,6 +20,7 @@ filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [
|
||||
":package-srcs",
|
||||
"//staging/src/k8s.io/cri-api/pkg/apis/runtime/v1:all-srcs",
|
||||
"//staging/src/k8s.io/cri-api/pkg/apis/runtime/v1alpha2:all-srcs",
|
||||
"//staging/src/k8s.io/cri-api/pkg/apis/testing:all-srcs",
|
||||
],
|
||||
|
34
staging/src/k8s.io/cri-api/pkg/apis/runtime/v1/BUILD
Normal file
34
staging/src/k8s.io/cri-api/pkg/apis/runtime/v1/BUILD
Normal file
@ -0,0 +1,34 @@
|
||||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"api.pb.go",
|
||||
"constants.go",
|
||||
],
|
||||
importmap = "k8s.io/kubernetes/vendor/k8s.io/cri-api/pkg/apis/runtime/v1",
|
||||
importpath = "k8s.io/cri-api/pkg/apis/runtime/v1",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//vendor/github.com/gogo/protobuf/gogoproto:go_default_library",
|
||||
"//vendor/github.com/gogo/protobuf/proto:go_default_library",
|
||||
"//vendor/github.com/gogo/protobuf/sortkeys:go_default_library",
|
||||
"//vendor/google.golang.org/grpc:go_default_library",
|
||||
"//vendor/google.golang.org/grpc/codes:go_default_library",
|
||||
"//vendor/google.golang.org/grpc/status:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
34141
staging/src/k8s.io/cri-api/pkg/apis/runtime/v1/api.pb.go
Normal file
34141
staging/src/k8s.io/cri-api/pkg/apis/runtime/v1/api.pb.go
Normal file
File diff suppressed because it is too large
Load Diff
1336
staging/src/k8s.io/cri-api/pkg/apis/runtime/v1/api.proto
Normal file
1336
staging/src/k8s.io/cri-api/pkg/apis/runtime/v1/api.proto
Normal file
File diff suppressed because it is too large
Load Diff
55
staging/src/k8s.io/cri-api/pkg/apis/runtime/v1/constants.go
Normal file
55
staging/src/k8s.io/cri-api/pkg/apis/runtime/v1/constants.go
Normal file
@ -0,0 +1,55 @@
|
||||
/*
|
||||
Copyright 2020 The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package v1
|
||||
|
||||
// This file contains all constants defined in CRI.
|
||||
|
||||
// Required runtime condition type.
|
||||
const (
|
||||
// RuntimeReady means the runtime is up and ready to accept basic containers.
|
||||
RuntimeReady = "RuntimeReady"
|
||||
// NetworkReady means the runtime network is up and ready to accept containers which require network.
|
||||
NetworkReady = "NetworkReady"
|
||||
)
|
||||
|
||||
// LogStreamType is the type of the stream in CRI container log.
|
||||
type LogStreamType string
|
||||
|
||||
const (
|
||||
// Stdout is the stream type for stdout.
|
||||
Stdout LogStreamType = "stdout"
|
||||
// Stderr is the stream type for stderr.
|
||||
Stderr LogStreamType = "stderr"
|
||||
)
|
||||
|
||||
// LogTag is the tag of a log line in CRI container log.
|
||||
// Currently defined log tags:
|
||||
// * First tag: Partial/Full - P/F.
|
||||
// The field in the container log format can be extended to include multiple
|
||||
// tags by using a delimiter, but changes should be rare. If it becomes clear
|
||||
// that better extensibility is desired, a more extensible format (e.g., json)
|
||||
// should be adopted as a replacement and/or addition.
|
||||
type LogTag string
|
||||
|
||||
const (
|
||||
// LogTagPartial means the line is part of multiple lines.
|
||||
LogTagPartial LogTag = "P"
|
||||
// LogTagFull means the line is a single full line or the end of multiple lines.
|
||||
LogTagFull LogTag = "F"
|
||||
// LogTagDelimiter is the delimiter for different log tags.
|
||||
LogTagDelimiter = ":"
|
||||
)
|
Loading…
Reference in New Issue
Block a user