Merge pull request #973 from RainbowMango/pr_add_webhook_example
Setup webhook example structure
This commit is contained in:
commit
5a025ea3f1
|
@ -0,0 +1,4 @@
|
|||
# Examples
|
||||
|
||||
### Custom Resource Explorer
|
||||
This example implements a new CustomResourceDefinition(CRD), `Workload`, and creates a custom resource explorer webhook.
|
|
@ -0,0 +1,43 @@
|
|||
package v1alpha1
|
||||
|
||||
import (
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
// Workload is a simple Deployment.
|
||||
type Workload struct {
|
||||
metav1.TypeMeta `json:",inline"`
|
||||
metav1.ObjectMeta `json:"metadata,omitempty"`
|
||||
|
||||
// Spec represents the specification of the desired behavior.
|
||||
// +required
|
||||
Spec WorkloadSpec `json:"spec"`
|
||||
|
||||
// Status represents most recently observed status of the Workload.
|
||||
// +optional
|
||||
Status WorkloadStatus `json:"status,omitempty"`
|
||||
}
|
||||
|
||||
// WorkloadSpec is the specification of the desired behavior of the Workload.
|
||||
type WorkloadSpec struct {
|
||||
// Number of desired pods. This is a pointer to distinguish between explicit
|
||||
// zero and not specified. Defaults to 1.
|
||||
// +optional
|
||||
Replicas *int32 `json:"replicas,omitempty"`
|
||||
|
||||
// Template describes the pods that will be created.
|
||||
Template corev1.PodTemplateSpec `json:"template" protobuf:"bytes,3,opt,name=template"`
|
||||
|
||||
// Paused indicates that the deployment is paused.
|
||||
// Note: both user and controllers might set this field.
|
||||
// +optional
|
||||
Paused bool `json:"paused,omitempty"`
|
||||
}
|
||||
|
||||
// WorkloadStatus represents most recently observed status of the Workload.
|
||||
type WorkloadStatus struct {
|
||||
// ReadyReplicas represents the total number of ready pods targeted by this Workload.
|
||||
// +optional
|
||||
ReadyReplicas int32 `json:"readyReplicas,omitempty"`
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
fmt.Printf("Place holder of the webhook.")
|
||||
}
|
Loading…
Reference in New Issue