diff --git a/chart/.helmignore b/chart/.helmignore index 0e8a0eb..056055d 100644 --- a/chart/.helmignore +++ b/chart/.helmignore @@ -1,23 +1,4 @@ # Patterns to ignore when building packages. # This supports shell glob matching, relative path matching, and # negation (prefixed with !). Only one pattern per line. -.DS_Store -# Common VCS dirs -.git/ -.gitignore -.bzr/ -.bzrignore -.hg/ -.hgignore -.svn/ -# Common backup files -*.swp -*.bak -*.tmp -*.orig -*~ -# Various IDEs -.project -.idea/ -*.tmproj -.vscode/ +samples/ diff --git a/chart/samples/api.txt b/chart/samples/api.txt new file mode 100644 index 0000000..2d7e7c1 --- /dev/null +++ b/chart/samples/api.txt @@ -0,0 +1,28 @@ +# Backend API Calls - Examples + +## Get a Widget + +### Calling an External API + +```sh +kubectl get widget.templates.krateo.io/external-api \ + --kubeconfig=$PWD/cyberjoker.json \ + -n demo-system -o yaml +``` + +### Calling an Internal API + +```sh +kubectl get widget.templates.krateo.io/internal-api \ + --kubeconfig=$PWD/cyberjoker.json \ + -n demo-system -o yaml +``` + +## Get a Form + +```sh +kubectl get form.templates.krateo.io/fireworksapp \ + --kubeconfig=$PWD/cyberjoker.json \ + -n demo-system -o yaml +``` + diff --git a/chart/samples/compositiondefinition.patch.yaml b/chart/samples/compositiondefinition.patch.yaml new file mode 100644 index 0000000..c26a3fc --- /dev/null +++ b/chart/samples/compositiondefinition.patch.yaml @@ -0,0 +1,5 @@ +status: + apiVersion: composition.krateo.io/v0-1-0 + kind: FireworksApp + packageUrl: "hello world" + diff --git a/chart/samples/compositiondefinition.yaml b/chart/samples/compositiondefinition.yaml new file mode 100644 index 0000000..0960c37 --- /dev/null +++ b/chart/samples/compositiondefinition.yaml @@ -0,0 +1,10 @@ +apiVersion: core.krateo.io/v1alpha1 +kind: CompositionDefinition +metadata: + annotations: + "krateo.io/connector-verbose": "true" + name: fireworksapp + namespace: demo-system +spec: + chart: + url: https://github.com/krateoplatformops/krateo-v2-template-fireworksapp/releases/download/0.1.0/fireworks-app-0.1.0.tgz \ No newline at end of file diff --git a/chart/samples/core.krateo.io_compositiondefinitions.yaml b/chart/samples/core.krateo.io_compositiondefinitions.yaml new file mode 100644 index 0000000..3247ceb --- /dev/null +++ b/chart/samples/core.krateo.io_compositiondefinitions.yaml @@ -0,0 +1,187 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.14.0 + name: compositiondefinitions.core.krateo.io +spec: + group: core.krateo.io + names: + categories: + - krateo + - defs + - core + kind: CompositionDefinition + listKind: CompositionDefinitionList + plural: compositiondefinitions + singular: compositiondefinition + scope: Namespaced + versions: + - additionalPrinterColumns: + - jsonPath: .status.conditions[?(@.type=='Ready')].status + name: READY + type: string + - jsonPath: .metadata.creationTimestamp + name: AGE + type: date + - jsonPath: .status.apiVersion + name: API VERSION + priority: 10 + type: string + - jsonPath: .status.kind + name: KIND + priority: 10 + type: string + - jsonPath: .status.packageUrl + name: PACKAGE URL + priority: 10 + type: string + name: v1alpha1 + schema: + openAPIV3Schema: + description: CompositionDefinition is a definition type with a spec and a + status. + properties: + apiVersion: + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources + type: string + kind: + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + type: string + metadata: + type: object + spec: + properties: + chart: + properties: + credentials: + description: 'Credentials: credentials for private repos' + properties: + passwordRef: + description: A SecretKeySelector is a reference to a secret + key in an arbitrary namespace. + properties: + key: + description: The key to select. + type: string + name: + description: Name of the referenced object. + type: string + namespace: + description: Namespace of the referenced object. + type: string + required: + - key + - name + - namespace + type: object + username: + type: string + required: + - passwordRef + - username + type: object + repo: + description: 'Repo: helm repo name (for helm repo urls only)' + maxLength: 256 + type: string + x-kubernetes-validations: + - message: Repo is immutable + rule: self == oldSelf + url: + description: 'Url: oci or tgz full url' + type: string + version: + description: 'Version: desired chart version' + maxLength: 20 + type: string + x-kubernetes-validations: + - message: Version is immutable + rule: self == oldSelf + required: + - url + type: object + x-kubernetes-validations: + - message: Version is required once set + rule: '!has(oldSelf.version) || has(self.version)' + - message: Repo is required once set + rule: '!has(oldSelf.repo) || has(self.repo)' + deletionPolicy: + default: Delete + description: |- + DeletionPolicy specifies what will happen to the underlying external + when this managed resource is deleted - either "Delete" or "Orphan" the + external resource. + enum: + - Orphan + - Delete + type: string + type: object + status: + description: CompositionDefinitionStatus is the status of a CompositionDefinition. + properties: + apiVersion: + description: 'APIVersion: the generated custom resource API version' + type: string + conditions: + description: Conditions of the resource. + items: + description: A Condition that may apply to a resource. + properties: + lastTransitionTime: + description: |- + LastTransitionTime is the last time this condition transitioned from one + status to another. + format: date-time + type: string + message: + description: |- + A Message containing details about this condition's last transition from + one status to another, if any. + type: string + reason: + description: A Reason for this condition's last transition from + one status to another. + type: string + status: + description: Status of this condition; is it currently True, + False, or Unknown? + type: string + type: + description: |- + Type of this condition. At most one of each condition type may apply to + a resource at any point in time. + type: string + required: + - lastTransitionTime + - reason + - status + - type + type: object + type: array + error: + description: 'Error: error messages - actually only used if an error + occurred during role and clusterrole creation' + type: string + kind: + description: 'Kind: the generated custom resource Kind' + type: string + packageUrl: + description: 'PackageURL: .tgz or oci chart direct url' + type: string + type: object + type: object + served: true + storage: true + subresources: + status: {} \ No newline at end of file diff --git a/chart/samples/endpoint.sample.yaml b/chart/samples/endpoint.sample.yaml new file mode 100644 index 0000000..c18a42c --- /dev/null +++ b/chart/samples/endpoint.sample.yaml @@ -0,0 +1,10 @@ +--- +apiVersion: v1 +kind: Secret +type: Opaque +metadata: + name: typicode-endpoint + namespace: demo-system +stringData: + server-url: https://jsonplaceholder.typicode.com +--- \ No newline at end of file diff --git a/chart/samples/form.sample.yaml b/chart/samples/form.sample.yaml new file mode 100644 index 0000000..2b4a804 --- /dev/null +++ b/chart/samples/form.sample.yaml @@ -0,0 +1,13 @@ +--- +apiVersion: templates.krateo.io/v1alpha1 +kind: Form +metadata: + name: fireworksapp + namespace: demo-system +spec: + # schemaDefinitionRef: + # name: fireworksapp + # namespace: demo-system + compositionDefinitionRef: + name: fireworksapp + namespace: demo-system diff --git a/chart/samples/rbac.composition.yaml b/chart/samples/rbac.composition.yaml new file mode 100644 index 0000000..c52209a --- /dev/null +++ b/chart/samples/rbac.composition.yaml @@ -0,0 +1,28 @@ +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: + name: compositions-viewer + namespace: demo-system +rules: +- apiGroups: + - composition.krateo.io + resources: + - '*' + verbs: + - get + - list +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: compositions-viewer + namespace: demo-system +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: compositions-viewer +subjects: +- kind: Group + name: devs + apiGroup: rbac.authorization.k8s.io diff --git a/chart/samples/rbac.compositiondefinitions.yaml b/chart/samples/rbac.compositiondefinitions.yaml new file mode 100644 index 0000000..f0262cf --- /dev/null +++ b/chart/samples/rbac.compositiondefinitions.yaml @@ -0,0 +1,28 @@ +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: + name: compositiondefinitions-viewer + namespace: demo-system +rules: +- apiGroups: + - core.krateo.io + resources: + - compositiondefinitions + verbs: + - get + - list +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: compositiondefinitions-viewer + namespace: demo-system +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: compositiondefinitions-viewer +subjects: +- kind: Group + name: devs + apiGroup: rbac.authorization.k8s.io \ No newline at end of file diff --git a/chart/samples/rbac.crds.yaml b/chart/samples/rbac.crds.yaml new file mode 100644 index 0000000..f1399cf --- /dev/null +++ b/chart/samples/rbac.crds.yaml @@ -0,0 +1,26 @@ +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: crds-viewer +rules: +- apiGroups: + - apiextensions.k8s.io + resources: + - customresourcedefinitions + verbs: + - get + - list +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: crds-viewer +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: crds-viewer +subjects: +- kind: Group + name: devs + apiGroup: rbac.authorization.k8s.io diff --git a/chart/samples/rbac.pods.yaml b/chart/samples/rbac.pods.yaml new file mode 100644 index 0000000..04a5798 --- /dev/null +++ b/chart/samples/rbac.pods.yaml @@ -0,0 +1,27 @@ +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: pods-viewer +rules: +- apiGroups: + - '' + resources: + - pods + - pods/status + verbs: + - get + - list +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: pods-viewer +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: pods-viewer +subjects: +- kind: Group + name: devs + apiGroup: rbac.authorization.k8s.io diff --git a/chart/samples/rbac.templates.yaml b/chart/samples/rbac.templates.yaml new file mode 100644 index 0000000..6e5d963 --- /dev/null +++ b/chart/samples/rbac.templates.yaml @@ -0,0 +1,28 @@ +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: + name: widgets-viewer + namespace: demo-system +rules: +- apiGroups: + - templates.krateo.io + resources: + - '*' + verbs: + - get + - list +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: widgets-viewer + namespace: demo-system +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: widgets-viewer +subjects: +- kind: Group + name: devs + apiGroup: rbac.authorization.k8s.io \ No newline at end of file diff --git a/chart/samples/users.json b/chart/samples/users.json new file mode 100644 index 0000000..8fbbf64 --- /dev/null +++ b/chart/samples/users.json @@ -0,0 +1,236 @@ +{ + "api2": { + "items": [ + { + "id": 1, + "name": "Leanne Graham", + "username": "Bret", + "email": "Sincere@april.biz", + "address": { + "street": "Kulas Light", + "suite": "Apt. 556", + "city": "Gwenborough", + "zipcode": "92998-3874", + "geo": { + "lat": "-37.3159", + "lng": "81.1496" + } + }, + "phone": "1-770-736-8031 x56442", + "website": "hildegard.org", + "company": { + "name": "Romaguera-Crona", + "catchPhrase": "Multi-layered client-server neural-net", + "bs": "harness real-time e-markets" + } + }, + { + "id": 2, + "name": "Ervin Howell", + "username": "Antonette", + "email": "Shanna@melissa.tv", + "address": { + "street": "Victor Plains", + "suite": "Suite 879", + "city": "Wisokyburgh", + "zipcode": "90566-7771", + "geo": { + "lat": "-43.9509", + "lng": "-34.4618" + } + }, + "phone": "010-692-6593 x09125", + "website": "anastasia.net", + "company": { + "name": "Deckow-Crist", + "catchPhrase": "Proactive didactic contingency", + "bs": "synergize scalable supply-chains" + } + }, + { + "id": 3, + "name": "Clementine Bauch", + "username": "Samantha", + "email": "Nathan@yesenia.net", + "address": { + "street": "Douglas Extension", + "suite": "Suite 847", + "city": "McKenziehaven", + "zipcode": "59590-4157", + "geo": { + "lat": "-68.6102", + "lng": "-47.0653" + } + }, + "phone": "1-463-123-4447", + "website": "ramiro.info", + "company": { + "name": "Romaguera-Jacobson", + "catchPhrase": "Face to face bifurcated interface", + "bs": "e-enable strategic applications" + } + }, + { + "id": 4, + "name": "Patricia Lebsack", + "username": "Karianne", + "email": "Julianne.OConner@kory.org", + "address": { + "street": "Hoeger Mall", + "suite": "Apt. 692", + "city": "South Elvis", + "zipcode": "53919-4257", + "geo": { + "lat": "29.4572", + "lng": "-164.2990" + } + }, + "phone": "493-170-9623 x156", + "website": "kale.biz", + "company": { + "name": "Robel-Corkery", + "catchPhrase": "Multi-tiered zero tolerance productivity", + "bs": "transition cutting-edge web services" + } + }, + { + "id": 5, + "name": "Chelsey Dietrich", + "username": "Kamren", + "email": "Lucio_Hettinger@annie.ca", + "address": { + "street": "Skiles Walks", + "suite": "Suite 351", + "city": "Roscoeview", + "zipcode": "33263", + "geo": { + "lat": "-31.8129", + "lng": "62.5342" + } + }, + "phone": "(254)954-1289", + "website": "demarco.info", + "company": { + "name": "Keebler LLC", + "catchPhrase": "User-centric fault-tolerant solution", + "bs": "revolutionize end-to-end systems" + } + }, + { + "id": 6, + "name": "Mrs. Dennis Schulist", + "username": "Leopoldo_Corkery", + "email": "Karley_Dach@jasper.info", + "address": { + "street": "Norberto Crossing", + "suite": "Apt. 950", + "city": "South Christy", + "zipcode": "23505-1337", + "geo": { + "lat": "-71.4197", + "lng": "71.7478" + } + }, + "phone": "1-477-935-8478 x6430", + "website": "ola.org", + "company": { + "name": "Considine-Lockman", + "catchPhrase": "Synchronised bottom-line interface", + "bs": "e-enable innovative applications" + } + }, + { + "id": 7, + "name": "Kurtis Weissnat", + "username": "Elwyn.Skiles", + "email": "Telly.Hoeger@billy.biz", + "address": { + "street": "Rex Trail", + "suite": "Suite 280", + "city": "Howemouth", + "zipcode": "58804-1099", + "geo": { + "lat": "24.8918", + "lng": "21.8984" + } + }, + "phone": "210.067.6132", + "website": "elvis.io", + "company": { + "name": "Johns Group", + "catchPhrase": "Configurable multimedia task-force", + "bs": "generate enterprise e-tailers" + } + }, + { + "id": 8, + "name": "Nicholas Runolfsdottir V", + "username": "Maxime_Nienow", + "email": "Sherwood@rosamond.me", + "address": { + "street": "Ellsworth Summit", + "suite": "Suite 729", + "city": "Aliyaview", + "zipcode": "45169", + "geo": { + "lat": "-14.3990", + "lng": "-120.7677" + } + }, + "phone": "586.493.6943 x140", + "website": "jacynthe.com", + "company": { + "name": "Abernathy Group", + "catchPhrase": "Implemented secondary concept", + "bs": "e-enable extensible e-tailers" + } + }, + { + "id": 9, + "name": "Glenna Reichert", + "username": "Delphine", + "email": "Chaim_McDermott@dana.io", + "address": { + "street": "Dayna Park", + "suite": "Suite 449", + "city": "Bartholomebury", + "zipcode": "76495-3109", + "geo": { + "lat": "24.6463", + "lng": "-168.8889" + } + }, + "phone": "(775)976-6794 x41206", + "website": "conrad.com", + "company": { + "name": "Yost and Sons", + "catchPhrase": "Switchable contextually-based project", + "bs": "aggregate real-time technologies" + } + }, + { + "id": 10, + "name": "Clementina DuBuque", + "username": "Moriah.Stanton", + "email": "Rey.Padberg@karina.biz", + "address": { + "street": "Kattie Turnpike", + "suite": "Suite 198", + "city": "Lebsackbury", + "zipcode": "31428-2261", + "geo": { + "lat": "-38.2386", + "lng": "57.2232" + } + }, + "phone": "024-648-3804", + "website": "ambrose.net", + "company": { + "name": "Hoeger LLC", + "catchPhrase": "Centralized empowering task-force", + "bs": "target end-to-end models" + } + } + ] + } +} \ No newline at end of file diff --git a/chart/samples/widgets.card.sample.yaml b/chart/samples/widgets.card.sample.yaml new file mode 100644 index 0000000..112bd28 --- /dev/null +++ b/chart/samples/widgets.card.sample.yaml @@ -0,0 +1,121 @@ +kind: ConfigMap +apiVersion: v1 +metadata: + name: card-props + namespace: demo-system +data: + bgColor: "#1f1e33" + fgColor: "#fff280" +--- +apiVersion: v1 +kind: Secret +type: Opaque +metadata: + name: typicode-endpoint + namespace: demo-system +stringData: + server-url: https://jsonplaceholder.typicode.com +--- +apiVersion: templates.krateo.io/v1alpha1 +kind: Widget +metadata: + name: static + namespace: demo-system +spec: + type: card + propsRef: + name: card-props + namespace: demo-system + actions: + - template: + apiVersion: templates.krateo.io/v1alpha1 + resource: forms + name: fireworksapp + namespace: demo-system + app: + template: + color: red + title: Lorem Ipsum + content: |- + Nulla quam lectus, venenatis at nunc nec, suscipit convallis sapien. + Suspendisse id venenatis orci, a semper ante. + Mauris convallis sagittis tincidunt. + Aenean egestas auctor interdum. + tags: lorem,ipsum +--- +apiVersion: templates.krateo.io/v1alpha1 +kind: Widget +metadata: + #annotations: + # "krateo.io/verbose-api": "true" + name: external-api + namespace: demo-system +spec: + type: card + propsRef: + name: card-props + namespace: demo-system + actions: + - template: + apiVersion: templates.krateo.io/v1alpha1 + resource: forms + name: fireworksapp + namespace: demo-system + - template: + apiVersion: templates.krateo.io/v1alpha1 + resource: widgets + name: external-api + namespace: demo-system + app: + template: + title: ${ .api2.items[0] | (.name + " -> " + .email) } + content: ${ .api2.items[0].body } + api: + - name: api1 + path: "/todos/1" + endpointRef: + name: typicode-endpoint + namespace: demo-system + verb: GET + headers: + - 'Accept: application/json' + - name: api2 + dependOn: api1 + path: ${ "/todos/" + (.api1.id|tostring) + "/comments" } + endpointRef: + name: typicode-endpoint + namespace: demo-system + verb: GET + headers: + - 'Accept: application/json' +--- +apiVersion: templates.krateo.io/v1alpha1 +kind: Widget +metadata: + #annotations: + # "krateo.io/verbose-api": "true" + name: internal-api + namespace: demo-system +spec: + type: card + propsRef: + name: card-props + namespace: demo-system + actions: + - iterator: .allPods.items[:3] + template: + apiVersion: v1 + resource: pods + name: ${ .metadata.name } + namespace: ${ .metadata.namespace } + app: + iterator: .allPods.items[:5] + template: + title: ${ .metadata.name } + content: ${ .spec.containers[0] | .image } + api: + - name: allPods + path: "/api/v1/pods" + verb: GET + headers: + - 'Accept: application/json' diff --git a/chart/samples/widgets.collections.sample.yaml b/chart/samples/widgets.collections.sample.yaml new file mode 100644 index 0000000..d9ca280 --- /dev/null +++ b/chart/samples/widgets.collections.sample.yaml @@ -0,0 +1,53 @@ +kind: ConfigMap +apiVersion: v1 +metadata: + name: column-props + namespace: demo-system +data: + bgColor: "#1f1e33" + width: "800" +--- +apiVersion: templates.krateo.io/v1alpha1 +kind: Collection +metadata: + name: column + namespace: demo-system +spec: + type: column + propsRef: + name: column-props + namespace: demo-system + widgetsRefs: + - apiVersion: templates.krateo.io/v1alpha1 + resource: widgets + name: static + namespace: demo-system + - apiVersion: templates.krateo.io/v1alpha1 + resource: widgets + name: external-api + namespace: demo-system +--- +kind: ConfigMap +apiVersion: v1 +metadata: + name: row-props + namespace: demo-system +data: + bgColor: "#1f1e33" + height: "100" +--- +apiVersion: templates.krateo.io/v1alpha1 +kind: Collection +metadata: + name: row + namespace: demo-system +spec: + type: row + propsRef: + name: row-props + namespace: demo-system + widgetsRefs: + - apiVersion: templates.krateo.io/v1alpha1 + resource: collections + name: column + namespace: demo-system