Skip to content

Instantly share code, notes, and snippets.

@Capstan
Created November 4, 2019 12:01
Show Gist options
  • Save Capstan/797ebcc97a2d3089f563e33cbab15f5d to your computer and use it in GitHub Desktop.
Save Capstan/797ebcc97a2d3089f563e33cbab15f5d to your computer and use it in GitHub Desktop.
Stock GKE CRD and user-provided CRD Kubernetes actuation
resources:
- name: crd-cluster
properties:
cluster:
initialClusterVersion: "1.14"
enableKubernetesAlpha: True
locations:
- us-central1-f
name: crd
nodePools:
- config:
diskSizeGb: 100
diskType: pd-standard
imageType: cos
machineType: n1-standard-2
oauthScopes:
- https://www.googleapis.com/auth/devstorage.read_only
- https://www.googleapis.com/auth/logging.write
- https://www.googleapis.com/auth/monitoring
- https://www.googleapis.com/auth/trace.append
initialNodeCount: 1
management: {}
name: default
zone: us-central1-f
type: container.v1.cluster
- metadata:
dependsOn:
- crd-cluster
name: crd-types
properties:
collectionOverrides:
- collection: /api/v1/namespaces/{namespace}/services/{name}
options:
inputMappings:
- fieldName: spec.clusterIP
location: BODY
methodMatch: ^(put|patch)$
value: $.resource.self.spec.clusterIP
descriptorUrl: https://$(ref.crd-cluster.endpoint)/openapi/v2
options:
inputMappings:
- fieldName: metadata.resourceVersion
location: BODY
methodMatch: ^(put|patch)$
value: $.resource.self.metadata.resourceVersion
- fieldName: id
location: PATH
methodMatch: ^(put|get|delete|post|patch)$
value: $.resource.properties.id
- fieldName: name
location: PATH
methodMatch: ^(put|get|delete|post|patch)$
value: $.resource.properties.metadata.name
- fieldName: namespace
location: PATH
methodMatch: ^(put|get|delete|post|patch)$
value: $.resource.properties.namespace
- fieldName: Authorization
location: HEADER
value: $.concat("Bearer ", $.googleOauth2AccessToken())
validationOptions:
schemaValidation: IGNORE
type: deploymentmanager.v2beta.typeProvider
- metadata:
dependsOn:
- crd-types
name: crd-backendconfig
type: {{ env["project"] }}/crd-types:/apis/cloud.google.com/v1beta1/namespaces/{namespace}/backendconfigs/{name}
properties:
apiVersion: cloud.google.com/v1beta1
kind: BackendConfig
metadata:
name: example
namespace: default
properties:
cdn:
enabled: false
# https://v1-14.docs.kubernetes.io/docs/tasks/access-kubernetes-api/custom-resources/custom-resource-definitions/
- metadata:
dependsOn:
- crd-types
name: crd-crontab-crd
type: {{ env["project"] }}/crd-types:/apis/apiextensions.k8s.io/v1beta1/customresourcedefinitions/{name}
properties:
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
# name must match the spec fields below, and be in the form: <plural>.<group>
name: crontabs.stable.example.com
spec:
# group name to use for REST API: /apis/<group>/<version>
group: stable.example.com
# list of versions supported by this CustomResourceDefinition
versions:
- name: v1
# Each version can be enabled/disabled by Served flag.
served: true
# One and only one version must be marked as the storage version.
storage: true
# either Namespaced or Cluster
scope: Namespaced
names:
# plural name to be used in the URL: /apis/<group>/<version>/<plural>
plural: crontabs
# singular name to be used as an alias on the CLI and for display
singular: crontab
# kind is normally the CamelCased singular type. Your resource manifests use this.
kind: CronTab
# shortNames allow shorter string to match your resource on the CLI
shortNames:
- ct
- metadata:
dependsOn:
- crd-crontab-crd
name: crd-crontab
type: {{ env["project"] }}/crd-types:/apis/stable.example.com/v1/namespaces/{namespace}/crontabs/{name}
properties:
apiVersion: "stable.example.com/v1"
kind: CronTab
metadata:
name: my-new-cron-object
namespace: default
spec:
cronSpec: "* * * * */5"
image: my-awesome-cron-image
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment