Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
530c7993
Commit
530c7993
authored
Sep 03, 2018
by
Mehdy Bohlool
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
API Types for CRD conversion
parent
f9c744ac
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
229 additions
and
4 deletions
+229
-4
types.go
pkg/apis/admissionregistration/types.go
+1
-1
types.go
pkg/apis/auditregistration/types.go
+1
-1
types.go
...ing/src/k8s.io/api/admissionregistration/v1beta1/types.go
+1
-1
types.go
staging/src/k8s.io/api/auditregistration/v1alpha1/types.go
+1
-1
types.go
...o/apiextensions-apiserver/pkg/apis/apiextensions/types.go
+88
-0
register.go
...ions-apiserver/pkg/apis/apiextensions/v1beta1/register.go
+1
-0
types.go
...ensions-apiserver/pkg/apis/apiextensions/v1beta1/types.go
+136
-0
No files found.
pkg/apis/admissionregistration/types.go
View file @
530c7993
...
@@ -290,7 +290,7 @@ const (
...
@@ -290,7 +290,7 @@ const (
// connection with the webhook
// connection with the webhook
type
WebhookClientConfig
struct
{
type
WebhookClientConfig
struct
{
// `url` gives the location of the webhook, in standard URL form
// `url` gives the location of the webhook, in standard URL form
// (`
[scheme://]
host:port/path`). Exactly one of `url` or `service`
// (`
scheme://
host:port/path`). Exactly one of `url` or `service`
// must be specified.
// must be specified.
//
//
// The `host` should not refer to a service running in the cluster; use
// The `host` should not refer to a service running in the cluster; use
...
...
pkg/apis/auditregistration/types.go
View file @
530c7993
...
@@ -135,7 +135,7 @@ type WebhookThrottleConfig struct {
...
@@ -135,7 +135,7 @@ type WebhookThrottleConfig struct {
// WebhookClientConfig contains the information to make a connection with the webhook
// WebhookClientConfig contains the information to make a connection with the webhook
type
WebhookClientConfig
struct
{
type
WebhookClientConfig
struct
{
// `url` gives the location of the webhook, in standard URL form
// `url` gives the location of the webhook, in standard URL form
// (`
[scheme://]
host:port/path`). Exactly one of `url` or `service`
// (`
scheme://
host:port/path`). Exactly one of `url` or `service`
// must be specified.
// must be specified.
//
//
// The `host` should not refer to a service running in the cluster; use
// The `host` should not refer to a service running in the cluster; use
...
...
staging/src/k8s.io/api/admissionregistration/v1beta1/types.go
View file @
530c7993
...
@@ -246,7 +246,7 @@ const (
...
@@ -246,7 +246,7 @@ const (
// connection with the webhook
// connection with the webhook
type
WebhookClientConfig
struct
{
type
WebhookClientConfig
struct
{
// `url` gives the location of the webhook, in standard URL form
// `url` gives the location of the webhook, in standard URL form
// (`
[scheme://]
host:port/path`). Exactly one of `url` or `service`
// (`
scheme://
host:port/path`). Exactly one of `url` or `service`
// must be specified.
// must be specified.
//
//
// The `host` should not refer to a service running in the cluster; use
// The `host` should not refer to a service running in the cluster; use
...
...
staging/src/k8s.io/api/auditregistration/v1alpha1/types.go
View file @
530c7993
...
@@ -133,7 +133,7 @@ type WebhookThrottleConfig struct {
...
@@ -133,7 +133,7 @@ type WebhookThrottleConfig struct {
// WebhookClientConfig contains the information to make a connection with the webhook
// WebhookClientConfig contains the information to make a connection with the webhook
type
WebhookClientConfig
struct
{
type
WebhookClientConfig
struct
{
// `url` gives the location of the webhook, in standard URL form
// `url` gives the location of the webhook, in standard URL form
// (`
[scheme://]
host:port/path`). Exactly one of `url` or `service`
// (`
scheme://
host:port/path`). Exactly one of `url` or `service`
// must be specified.
// must be specified.
//
//
// The `host` should not refer to a service running in the cluster; use
// The `host` should not refer to a service running in the cluster; use
...
...
staging/src/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/types.go
View file @
530c7993
...
@@ -20,6 +20,16 @@ import (
...
@@ -20,6 +20,16 @@ import (
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
)
)
// ConversionStrategyType describes different conversion types.
type
ConversionStrategyType
string
const
(
// NoneConverter is a converter that only sets apiversion of the CR and leave everything else unchanged.
NoneConverter
ConversionStrategyType
=
"None"
// WebhookConverter is a converter that calls to an external webhook to convert the CR.
WebhookConverter
ConversionStrategyType
=
"Webhook"
)
// CustomResourceDefinitionSpec describes how a user wants their resource to appear
// CustomResourceDefinitionSpec describes how a user wants their resource to appear
type
CustomResourceDefinitionSpec
struct
{
type
CustomResourceDefinitionSpec
struct
{
// Group is the group this resource belongs in
// Group is the group this resource belongs in
...
@@ -51,8 +61,86 @@ type CustomResourceDefinitionSpec struct {
...
@@ -51,8 +61,86 @@ type CustomResourceDefinitionSpec struct {
Versions
[]
CustomResourceDefinitionVersion
Versions
[]
CustomResourceDefinitionVersion
// AdditionalPrinterColumns are additional columns shown e.g. in kubectl next to the name. Defaults to a created-at column.
// AdditionalPrinterColumns are additional columns shown e.g. in kubectl next to the name. Defaults to a created-at column.
AdditionalPrinterColumns
[]
CustomResourceColumnDefinition
AdditionalPrinterColumns
[]
CustomResourceColumnDefinition
// `conversion` defines conversion settings for the CRD.
Conversion
*
CustomResourceConversion
}
// CustomResourceConversion describes how to convert different versions of a CR.
type
CustomResourceConversion
struct
{
// `strategy` specifies the conversion strategy. Allowed values are:
// - `None`: The converter only change the apiVersion and would not touch any other field in the CR.
// - `Webhook`: API Server will call to an external webhook to do the conversion. Additional information is needed for this option.
Strategy
ConversionStrategyType
// `webhookClientConfig` is the instructions for how to call the webhook if strategy is `Webhook`.
WebhookClientConfig
*
WebhookClientConfig
}
// WebhookClientConfig contains the information to make a TLS
// connection with the webhook. It has the same field as admissionregistration.internal.WebhookClientConfig.
type
WebhookClientConfig
struct
{
// `url` gives the location of the webhook, in standard URL form
// (`scheme://host:port/path`). Exactly one of `url` or `service`
// must be specified.
//
// The `host` should not refer to a service running in the cluster; use
// the `service` field instead. The host might be resolved via external
// DNS in some apiservers (e.g., `kube-apiserver` cannot resolve
// in-cluster DNS as that would be a layering violation). `host` may
// also be an IP address.
//
// Please note that using `localhost` or `127.0.0.1` as a `host` is
// risky unless you take great care to run this webhook on all hosts
// which run an apiserver which might need to make calls to this
// webhook. Such installs are likely to be non-portable, i.e., not easy
// to turn up in a new cluster.
//
// The scheme must be "https"; the URL must begin with "https://".
//
// A path is optional, and if present may be any string permissible in
// a URL. You may use the path to pass an arbitrary string to the
// webhook, for example, a cluster identifier.
//
// Attempting to use a user or basic auth e.g. "user:password@" is not
// allowed. Fragments ("#...") and query parameters ("?...") are not
// allowed, either.
//
// +optional
URL
*
string
// `service` is a reference to the service for this webhook. Either
// `service` or `url` must be specified.
//
// If the webhook is running within the cluster, then you should use `service`.
//
// Port 443 will be used if it is open, otherwise it is an error.
//
// +optional
Service
*
ServiceReference
// `caBundle` is a PEM encoded CA bundle which will be used to validate the webhook's server certificate.
// If unspecified, system trust roots on the apiserver are used.
// +optional
CABundle
[]
byte
}
// ServiceReference holds a reference to Service.legacy.k8s.io
type
ServiceReference
struct
{
// `namespace` is the namespace of the service.
// Required
Namespace
string
// `name` is the name of the service.
// Required
Name
string
// `path` is an optional URL path which will be sent in any request to
// this service.
// +optional
Path
*
string
}
}
// CustomResourceDefinitionVersion describes a version for CRD.
type
CustomResourceDefinitionVersion
struct
{
type
CustomResourceDefinitionVersion
struct
{
// Name is the version name, e.g. “v1”, “v2beta1”, etc.
// Name is the version name, e.g. “v1”, “v2beta1”, etc.
Name
string
Name
string
...
...
staging/src/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/register.go
View file @
530c7993
...
@@ -48,6 +48,7 @@ func addKnownTypes(scheme *runtime.Scheme) error {
...
@@ -48,6 +48,7 @@ func addKnownTypes(scheme *runtime.Scheme) error {
scheme
.
AddKnownTypes
(
SchemeGroupVersion
,
scheme
.
AddKnownTypes
(
SchemeGroupVersion
,
&
CustomResourceDefinition
{},
&
CustomResourceDefinition
{},
&
CustomResourceDefinitionList
{},
&
CustomResourceDefinitionList
{},
&
ConversionReview
{},
)
)
metav1
.
AddToGroupVersion
(
scheme
,
SchemeGroupVersion
)
metav1
.
AddToGroupVersion
(
scheme
,
SchemeGroupVersion
)
return
nil
return
nil
...
...
staging/src/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1/types.go
View file @
530c7993
...
@@ -18,6 +18,18 @@ package v1beta1
...
@@ -18,6 +18,18 @@ package v1beta1
import
(
import
(
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
)
// ConversionStrategyType describes different conversion types.
type
ConversionStrategyType
string
const
(
// NoneConverter is a converter that only sets apiversion of the CR and leave everything else unchanged.
NoneConverter
ConversionStrategyType
=
"None"
// WebhookConverter is a converter that calls to an external webhook to convert the CR.
WebhookConverter
ConversionStrategyType
=
"Webhook"
)
)
// CustomResourceDefinitionSpec describes how a user wants their resource to appear
// CustomResourceDefinitionSpec describes how a user wants their resource to appear
...
@@ -56,8 +68,89 @@ type CustomResourceDefinitionSpec struct {
...
@@ -56,8 +68,89 @@ type CustomResourceDefinitionSpec struct {
// AdditionalPrinterColumns are additional columns shown e.g. in kubectl next to the name. Defaults to a created-at column.
// AdditionalPrinterColumns are additional columns shown e.g. in kubectl next to the name. Defaults to a created-at column.
// +optional
// +optional
AdditionalPrinterColumns
[]
CustomResourceColumnDefinition
`json:"additionalPrinterColumns,omitempty" protobuf:"bytes,8,rep,name=additionalPrinterColumns"`
AdditionalPrinterColumns
[]
CustomResourceColumnDefinition
`json:"additionalPrinterColumns,omitempty" protobuf:"bytes,8,rep,name=additionalPrinterColumns"`
// `conversion` defines conversion settings for the CRD.
// +optional
Conversion
*
CustomResourceConversion
`json:"conversion,omitempty" protobuf:"bytes,9,opt,name=conversion"`
}
// CustomResourceConversion describes how to convert different versions of a CR.
type
CustomResourceConversion
struct
{
// `strategy` specifies the conversion strategy. Allowed values are:
// - `None`: The converter only change the apiVersion and would not touch any other field in the CR.
// - `Webhook`: API Server will call to an external webhook to do the conversion. Additional information is needed for this option.
Strategy
ConversionStrategyType
`json:"strategy" protobuf:"bytes,1,name=strategy"`
// `webhookClientConfig` is the instructions for how to call the webhook if strategy is `Webhook`. This field is
// alpha-level and is only honored by servers that enable the CustomResourceWebhookConversion feature.
// +optional
WebhookClientConfig
*
WebhookClientConfig
`json:"webhookClientConfig,omitempty" protobuf:"bytes,2,name=webhookClientConfig"`
}
// WebhookClientConfig contains the information to make a TLS
// connection with the webhook. It has the same field as admissionregistration.v1beta1.WebhookClientConfig.
type
WebhookClientConfig
struct
{
// `url` gives the location of the webhook, in standard URL form
// (`scheme://host:port/path`). Exactly one of `url` or `service`
// must be specified.
//
// The `host` should not refer to a service running in the cluster; use
// the `service` field instead. The host might be resolved via external
// DNS in some apiservers (e.g., `kube-apiserver` cannot resolve
// in-cluster DNS as that would be a layering violation). `host` may
// also be an IP address.
//
// Please note that using `localhost` or `127.0.0.1` as a `host` is
// risky unless you take great care to run this webhook on all hosts
// which run an apiserver which might need to make calls to this
// webhook. Such installs are likely to be non-portable, i.e., not easy
// to turn up in a new cluster.
//
// The scheme must be "https"; the URL must begin with "https://".
//
// A path is optional, and if present may be any string permissible in
// a URL. You may use the path to pass an arbitrary string to the
// webhook, for example, a cluster identifier.
//
// Attempting to use a user or basic auth e.g. "user:password@" is not
// allowed. Fragments ("#...") and query parameters ("?...") are not
// allowed, either.
//
// +optional
URL
*
string
`json:"url,omitempty" protobuf:"bytes,3,opt,name=url"`
// `service` is a reference to the service for this webhook. Either
// `service` or `url` must be specified.
//
// If the webhook is running within the cluster, then you should use `service`.
//
// Port 443 will be used if it is open, otherwise it is an error.
//
// +optional
Service
*
ServiceReference
`json:"service,omitempty" protobuf:"bytes,1,opt,name=service"`
// `caBundle` is a PEM encoded CA bundle which will be used to validate the webhook's server certificate.
// If unspecified, system trust roots on the apiserver are used.
// +optional
CABundle
[]
byte
`json:"caBundle,omitempty" protobuf:"bytes,2,opt,name=caBundle"`
}
// ServiceReference holds a reference to Service.legacy.k8s.io
type
ServiceReference
struct
{
// `namespace` is the namespace of the service.
// Required
Namespace
string
`json:"namespace" protobuf:"bytes,1,opt,name=namespace"`
// `name` is the name of the service.
// Required
Name
string
`json:"name" protobuf:"bytes,2,opt,name=name"`
// `path` is an optional URL path which will be sent in any request to
// this service.
// +optional
Path
*
string
`json:"path,omitempty" protobuf:"bytes,3,opt,name=path"`
}
}
// CustomResourceDefinitionVersion describes a version for CRD.
type
CustomResourceDefinitionVersion
struct
{
type
CustomResourceDefinitionVersion
struct
{
// Name is the version name, e.g. “v1”, “v2beta1”, etc.
// Name is the version name, e.g. “v1”, “v2beta1”, etc.
Name
string
`json:"name" protobuf:"bytes,1,opt,name=name"`
Name
string
`json:"name" protobuf:"bytes,1,opt,name=name"`
...
@@ -263,3 +356,46 @@ type CustomResourceSubresourceScale struct {
...
@@ -263,3 +356,46 @@ type CustomResourceSubresourceScale struct {
// +optional
// +optional
LabelSelectorPath
*
string
`json:"labelSelectorPath,omitempty" protobuf:"bytes,3,opt,name=labelSelectorPath"`
LabelSelectorPath
*
string
`json:"labelSelectorPath,omitempty" protobuf:"bytes,3,opt,name=labelSelectorPath"`
}
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// ConversionReview describes a conversion request/response.
type
ConversionReview
struct
{
metav1
.
TypeMeta
`json:",inline"`
// `request` describes the attributes for the conversion request.
// +optional
Request
*
ConversionRequest
`json:"request,omitempty" protobuf:"bytes,1,opt,name=request"`
// `response` describes the attributes for the conversion response.
// +optional
Response
*
ConversionResponse
`json:"response,omitempty" protobuf:"bytes,2,opt,name=response"`
}
// ConversionRequest describes the conversion request parameters.
type
ConversionRequest
struct
{
// `uid` is an identifier for the individual request/response. It allows us to distinguish instances of requests which are
// otherwise identical (parallel requests, requests when earlier requests did not modify etc)
// The UID is meant to track the round trip (request/response) between the KAS and the WebHook, not the user request.
// It is suitable for correlating log entries between the webhook and apiserver, for either auditing or debugging.
UID
types
.
UID
`json:"uid" protobuf:"bytes,1,name=uid"`
// `desiredAPIVersion` is the version to convert given objects to. e.g. "myapi.example.com/v1"
DesiredAPIVersion
string
`json:"desiredAPIVersion" protobuf:"bytes,2,name=desiredAPIVersion"`
// `objects` is the list of CR objects to be converted.
Objects
[]
runtime
.
RawExtension
`json:"objects" protobuf:"bytes,3,rep,name=objects"`
}
// ConversionResponse describes a conversion response.
type
ConversionResponse
struct
{
// `uid` is an identifier for the individual request/response.
// This should be copied over from the corresponding AdmissionRequest.
UID
types
.
UID
`json:"uid" protobuf:"bytes,1,name=uid"`
// `convertedObjects` is the list of converted version of `request.objects` if the `result` is successful otherwise empty.
// The webhook is expected to set apiVersion of these objects to the ConversionRequest.desiredAPIVersion. The list
// must also has the same size as input list with the same objects in the same order(i.e. equal UIDs and object meta)
ConvertedObjects
[]
runtime
.
RawExtension
`json:"convertedObjects" protobuf:"bytes,2,rep,name=convertedObjects"`
// `result` contains the result of conversion with extra details if the conversion failed. `result.status` determines if
// the conversion failed or succeeded. The `result.status` field is required and represent the success or failure of the
// conversion. A successful conversion must set `result.status` to `Success`. A failed conversion must set
// `result.status` to `Failure` and provide more details in `result.message` and return http status 200. The `result.message`
// will be used to construct an error message for the end user.
Result
metav1
.
Status
`json:"result" protobuf:"bytes,3,name=result"`
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment