-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from kubeshop/olelensmar/deprecated-resources
Adds deprecated resources for showing the deprecation validation with the schema validator
- Loading branch information
Showing
11 changed files
with
269 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,5 +33,5 @@ spec: | |
ports: | ||
- name: http-web | ||
protocol: TCP | ||
port: "this-should-be-a-number" | ||
port: 81 | ||
targetPort: 8080 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
apiVersion: apiextensions.k8s.io/v1 | ||
kind: CustomResourceDefinition | ||
metadata: | ||
name: mycustomresources.example.com | ||
spec: | ||
group: example.com | ||
names: | ||
kind: MyCustomResource | ||
plural: mycustomresources | ||
singular: mycustomresource | ||
shortNames: | ||
- mcr | ||
scope: Namespaced | ||
versions: | ||
- name: v1 | ||
schema: | ||
openAPIV3Schema: | ||
type: object | ||
properties: | ||
spec: | ||
type: object | ||
x-kubernetes-validation: | ||
- rule: "self.replicas <= self.maxReplicas" | ||
message: "replicas must be less than or equal to maxReplicas" | ||
properties: | ||
replicas: | ||
type: integer | ||
maxReplicas: | ||
type: integer | ||
required: | ||
- replicas | ||
- maxReplicas |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
apiVersion: example.com/v1 | ||
kind: MyCustomResource | ||
metadata: | ||
name: example-demo | ||
spec: | ||
replicas: 10 | ||
maxReplicas: 20 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
apiVersion: batch/v1beta1 | ||
kind: CronJob | ||
metadata: | ||
name: job-1 | ||
labels: | ||
app: cj | ||
spec: | ||
schedule: "* * * * *" | ||
jobTemplate: | ||
spec: | ||
template: | ||
spec: | ||
containers: | ||
- name: hello | ||
image: busybox:1.28 | ||
imagePullPolicy: IfNotPresent | ||
command: | ||
- /bin/sh | ||
- -c | ||
- date; echo Hello from the Kubernetes cluster | ||
restartPolicy: OnFailure | ||
--- | ||
apiVersion: apps/v1beta2 | ||
kind: Deployment | ||
metadata: | ||
name: nginx-deployment | ||
labels: | ||
app: nginx | ||
spec: | ||
replicas: 5 | ||
rollbackTo: | ||
revision: 0 | ||
selector: | ||
matchLabels: | ||
app: nginx | ||
template: | ||
metadata: | ||
labels: | ||
app: nginx | ||
spec: | ||
containers: | ||
- name: nginx | ||
image: nginx:1.14.2 | ||
ports: | ||
- containerPort: 80 | ||
--- | ||
apiVersion: v1 | ||
kind: FlowSchema | ||
metadata: | ||
name: health-for-strangers | ||
spec: | ||
matchingPrecedence: 1000 | ||
priorityLevelConfiguration: | ||
name: exempt | ||
rules: | ||
- nonResourceRules: | ||
- nonResourceURLs: | ||
- "/healthz" | ||
- "/livez" | ||
- "/readyz" | ||
verbs: | ||
- "*" | ||
subjects: | ||
- kind: Group | ||
group: | ||
name: "system:unauthenticated" | ||
--- | ||
apiVersion: apps/v1beta1 | ||
kind: ReplicaSet | ||
metadata: | ||
name: frontend | ||
labels: | ||
app: guestbook | ||
tier: frontend | ||
spec: | ||
replicas: 3 | ||
selector: | ||
matchLabels: | ||
tier: frontend | ||
template: | ||
metadata: | ||
labels: | ||
tier: frontend | ||
spec: | ||
containers: | ||
- name: php-redis | ||
image: gcr.io/google_samples/gb-frontend:v3 | ||
--- | ||
apiVersion: storage.k8s.io/v1beta1 | ||
kind: StorageClass | ||
metadata: | ||
name: standard | ||
provisioner: kubernetes.io/aws-ebs | ||
parameters: | ||
type: gp2 | ||
reclaimPolicy: Retain | ||
allowVolumeExpansion: true | ||
mountOptions: | ||
- debug | ||
volumeBindingMode: Immediate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: demo | ||
labels: | ||
env: production | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: nginx-deployment | ||
namespace: demo | ||
labels: | ||
app: nginx | ||
env: production | ||
spec: | ||
replicas: 3 | ||
selector: | ||
matchLabels: | ||
app: nginx | ||
template: | ||
metadata: | ||
labels: | ||
app: nginx | ||
spec: | ||
containers: | ||
- name: nginx | ||
image: nginx:1.14.2 | ||
ports: | ||
- containerPort: 80 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
apiVersion: admissionregistration.k8s.io/v1beta1 | ||
kind: ValidatingAdmissionPolicy | ||
metadata: | ||
name: high-available-params | ||
spec: | ||
failurePolicy: Fail | ||
paramKind: | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
matchConstraints: | ||
resourceRules: | ||
- apiGroups: [ "apps" ] | ||
apiVersions: [ "v1" ] | ||
operations: [ "CREATE", "UPDATE" ] | ||
resources: [ "deployments" ] | ||
validations: | ||
- expression: "object.spec.replicas <= params.data.maxReplicas" | ||
message: "replicas must be less or equal to than maxReplicas" | ||
--- | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: rule-config | ||
namespace: demo | ||
data: | ||
maxReplicas: 4 | ||
--- | ||
apiVersion: admissionregistration.k8s.io/v1beta1 | ||
kind: ValidatingAdmissionPolicyBinding | ||
metadata: | ||
name: high-available-params | ||
spec: | ||
policyName: high-available-params | ||
validationActions: | ||
- Deny | ||
paramRef: | ||
name: rule-config | ||
namespace: demo | ||
matchResources: | ||
namespaceSelector: | ||
matchLabels: | ||
env: production |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
apiVersion: admissionregistration.k8s.io/v1beta1 | ||
kind: ValidatingAdmissionPolicy | ||
metadata: | ||
name: high-available | ||
spec: | ||
failurePolicy: Fail | ||
matchConstraints: | ||
resourceRules: | ||
- apiGroups: [ "apps" ] | ||
apiVersions: [ "v1" ] | ||
operations: [ "CREATE", "UPDATE" ] | ||
resources: [ "deployments" ] | ||
validations: | ||
- expression: "object.spec.replicas > 2" | ||
message: "replicas must be greater than 2" | ||
--- | ||
apiVersion: admissionregistration.k8s.io/v1beta1 | ||
kind: ValidatingAdmissionPolicyBinding | ||
metadata: | ||
name: high-available | ||
spec: | ||
policyName: high-available | ||
validationActions: [Deny] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
apiVersion: admissionregistration.k8s.io/v1beta1 | ||
kind: ValidatingAdmissionPolicy | ||
metadata: | ||
name: env-label | ||
spec: | ||
failurePolicy: Fail | ||
matchConstraints: | ||
resourceRules: | ||
- apiGroups: [ "apps" ] | ||
apiVersions: [ "v1" ] | ||
operations: [ "CREATE", "UPDATE" ] | ||
resources: [ "deployments" ] | ||
validations: | ||
- expression: "has(object.metadata.labels) && has(object.metadata.labels.env) && | ||
object.metadata.labels.env in ['production', 'staging']" | ||
message: Missing expected env label | ||
--- | ||
apiVersion: admissionregistration.k8s.io/v1beta1 | ||
kind: ValidatingAdmissionPolicyBinding | ||
metadata: | ||
name: env-label | ||
spec: | ||
policyName: env-label | ||
validationActions: [ Deny ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters