Setup webhook example structure

Signed-off-by: RainbowMango <qdurenhongcai@gmail.com>
This commit is contained in:
RainbowMango 2021-11-17 10:46:51 +08:00
parent 73f68c3a5c
commit db6941e68e
3 changed files with 54 additions and 0 deletions

4
examples/README.md Normal file
View File

@ -0,0 +1,4 @@
# Examples
### Custom Resource Explorer
This example implements a new CustomResourceDefinition(CRD), `Workload`, and creates a custom resource explorer webhook.

View File

@ -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"`
}

View File

@ -0,0 +1,7 @@
package main
import "fmt"
func main() {
fmt.Printf("Place holder of the webhook.")
}