|
| 1 | +/* |
| 2 | +Copyright AppsCode Inc. and Contributors |
| 3 | +
|
| 4 | +Licensed under the AppsCode Community License 1.0.0 (the "License"); |
| 5 | +you may not use this file except in compliance with the License. |
| 6 | +You may obtain a copy of the License at |
| 7 | +
|
| 8 | + https://github.com/appscode/licenses/raw/1.0.0/AppsCode-Community-1.0.0.md |
| 9 | +
|
| 10 | +Unless required by applicable law or agreed to in writing, software |
| 11 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +See the License for the specific language governing permissions and |
| 14 | +limitations under the License. |
| 15 | +*/ |
| 16 | + |
| 17 | +package v1alpha1 |
| 18 | + |
| 19 | +import ( |
| 20 | + core "k8s.io/api/core/v1" |
| 21 | + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 22 | + "kmodules.xyz/resource-metadata/apis/shared" |
| 23 | +) |
| 24 | + |
| 25 | +const ( |
| 26 | + ResourceKindRegcache = "Regcache" |
| 27 | + ResourceRegcache = "regcache" |
| 28 | + ResourceRegcaches = "regcaches" |
| 29 | +) |
| 30 | + |
| 31 | +// Regcache defines the schema for the regcache chart values. |
| 32 | + |
| 33 | +// +genclient |
| 34 | +// +genclient:skipVerbs=updateStatus |
| 35 | +// +k8s:openapi-gen=true |
| 36 | +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object |
| 37 | + |
| 38 | +// +kubebuilder:object:root=true |
| 39 | +// +kubebuilder:resource:path=regcaches,singular=regcache,categories={kubeops,appscode} |
| 40 | +type Regcache struct { |
| 41 | + metav1.TypeMeta `json:",inline,omitempty"` |
| 42 | + metav1.ObjectMeta `json:"metadata,omitempty"` |
| 43 | + Spec RegcacheSpec `json:"spec,omitempty"` |
| 44 | +} |
| 45 | + |
| 46 | +// RegcacheSpec is the schema for the regcache chart values. It deploys an |
| 47 | +// in-cluster pull-through Docker registry cache (CNCF Distribution / registry:3) |
| 48 | +// that transparently proxies images from an upstream registry (ghcr.io by |
| 49 | +// default), so that ghcr.io/appscode-charts images can be served from within |
| 50 | +// the cluster. |
| 51 | +type RegcacheSpec struct { |
| 52 | + Enabled bool `json:"enabled"` |
| 53 | + ReplicaCount int `json:"replicaCount"` |
| 54 | + //+optional |
| 55 | + NameOverride string `json:"nameOverride"` |
| 56 | + //+optional |
| 57 | + FullnameOverride string `json:"fullnameOverride"` |
| 58 | + // RegistryFQDN is the docker registry fqdn used to pull the registry image. |
| 59 | + RegistryFQDN string `json:"registryFQDN"` |
| 60 | + Image ImageReference `json:"image"` |
| 61 | + //+optional |
| 62 | + ImagePullSecrets []string `json:"imagePullSecrets"` |
| 63 | + // RemoteURL is the upstream registry that this instance proxies as a |
| 64 | + // pull-through cache. |
| 65 | + RemoteURL string `json:"remoteURL"` |
| 66 | + // TTL is how long a cached blob/manifest is kept before the pull-through |
| 67 | + // cache scheduler purges it. This is the only mechanism that frees disk: |
| 68 | + // the cache has no capacity-based (LRU) eviction, so lower values bound |
| 69 | + // disk usage at the cost of re-fetching from upstream more often. |
| 70 | + //+optional |
| 71 | + TTL string `json:"ttl"` |
| 72 | + // Username is an optional credential for authenticating against the |
| 73 | + // upstream registry. Leave empty for anonymous pulls. |
| 74 | + //+optional |
| 75 | + Username string `json:"username"` |
| 76 | + // Password is an optional credential for authenticating against the |
| 77 | + // upstream registry. Leave empty for anonymous pulls. |
| 78 | + //+optional |
| 79 | + Password string `json:"password"` |
| 80 | + //+optional |
| 81 | + PodAnnotations map[string]string `json:"podAnnotations"` |
| 82 | + //+optional |
| 83 | + PodSecurityContext *core.PodSecurityContext `json:"podSecurityContext"` |
| 84 | + //+optional |
| 85 | + SecurityContext *core.SecurityContext `json:"securityContext"` |
| 86 | + Service AceServiceSpec `json:"service"` |
| 87 | + Persistence RegcachePersistence `json:"persistence"` |
| 88 | + //+optional |
| 89 | + Resources core.ResourceRequirements `json:"resources"` |
| 90 | + //+optional |
| 91 | + NodeSelector map[string]string `json:"nodeSelector"` |
| 92 | + // If specified, the pod's tolerations. |
| 93 | + //+optional |
| 94 | + Tolerations []core.Toleration `json:"tolerations"` |
| 95 | + // If specified, the pod's scheduling constraints |
| 96 | + //+optional |
| 97 | + Affinity *core.Affinity `json:"affinity"` |
| 98 | + Infra RegcacheInfra `json:"infra"` |
| 99 | + //+optional |
| 100 | + Distro shared.DistroSpec `json:"distro"` |
| 101 | +} |
| 102 | + |
| 103 | +type RegcacheInfra struct { |
| 104 | + StorageClass LocalObjectReference `json:"storageClass"` |
| 105 | +} |
| 106 | + |
| 107 | +type RegcachePersistence struct { |
| 108 | + Enabled bool `json:"enabled"` |
| 109 | + StorageClass string `json:"storageClass"` |
| 110 | + AccessMode string `json:"accessMode"` |
| 111 | + Size string `json:"size"` |
| 112 | +} |
| 113 | + |
| 114 | +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object |
| 115 | + |
| 116 | +// RegcacheList is a list of Regcaches |
| 117 | +type RegcacheList struct { |
| 118 | + metav1.TypeMeta `json:",inline"` |
| 119 | + metav1.ListMeta `json:"metadata,omitempty"` |
| 120 | + // Items is a list of Regcache CRD objects |
| 121 | + Items []Regcache `json:"items,omitempty"` |
| 122 | +} |
0 commit comments