commit d99f23906b73ba963881cae939edd484f574a924 Author: Olaf Bohlen Date: Sun Jan 1 21:42:31 2023 +0100 initial bundle diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b25c15b --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*~ diff --git a/Containerfile b/Containerfile new file mode 100644 index 0000000..f51a677 --- /dev/null +++ b/Containerfile @@ -0,0 +1,11 @@ +FROM docker.eenfach.de/olbohlen/kshbase:latest +LABEL author="Olaf Bohlen " + +COPY receipt-processor.ksh /usr/local/bin/receipt-processor.ksh +RUN chmod 755 /usr/local/bin/receipt-processor.ksh && \ + useradd cookie && \ + dnf install -y jq curl + +USER cookie + +ENTRYPOINT ["/usr/local/bin/receipt-processor.ksh"] \ No newline at end of file diff --git a/cookie-crd.yaml b/cookie-crd.yaml new file mode 100644 index 0000000..2af44fb --- /dev/null +++ b/cookie-crd.yaml @@ -0,0 +1,97 @@ +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + name: cookiereceipts.de.eenfach.olbohlen +spec: + group: de.eenfach.olbohlen + names: + kind: CookieReceipt + plural: cookiereceipts + singular: cookiereceipt + scope: Namespaced + versions: + - name: v1 + served: true + storage: true + schema: + openAPIV3Schema: + description: "The CookieReceipt CRD is a k8s demo for enhancing functionality, it will not (unfortunately) provide you real cookies in the end..." + type: object + 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: + type: string + 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' + metadata: + type: object + spec: + type: object + properties: + description: + type: string + description: please describe the cookie + source: + type: string + description: where does this come from? (grandma, mum, the internet...) + ingredients: + description: this list provides required ingredients for this receipt + type: array + x-kubernetes-list-type: atomic + items: + type: object + properties: + name: + type: string + description: specifies the ingredient + amount: + type: number + description: the amount + unit: + type: string + description: the unit for the amount + remarks: + type: string + description: additional remarks, i.e. "grandma always used to..." + required: + - name + - amount + - unit + steps: + description: the actual preparation steps + type: array + x-kubernetes-list-type: atomic + items: + type: object + properties: + order: + type: integer + description: the order number of the step + instruction: + type: string + description: the instruction text for this step + required: + - order + - instruction + temperature: + type: integer + description: temperature for the oven + sanescale: + type: boolean + description: if true or not defined, use Celsius-scale, else use Fahrenheit + preheat: + type: boolean + description: shall the oven be pre-heated, assume yes if undefined + duration: + type: integer + description: the amount of time in minutes to bake the cookies + required: + - ingredients + - steps + - temperature + - duration diff --git a/cookie-rbac.yaml b/cookie-rbac.yaml new file mode 100644 index 0000000..4cdbba0 --- /dev/null +++ b/cookie-rbac.yaml @@ -0,0 +1,43 @@ +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: cookiereceipt-edit +rules: +- apiGroups: + - de.eenfach.olbohlen + resources: + - cookiereceipts + verbs: + - create + - get + - list + - update + - patch + - delete +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: cookiereceipt-view +rules: +- apiGroups: + - de.eenfach.olbohlen + resources: + - cookiereceipts + verbs: + - get + - list +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: cookiereceipt-edit +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: cookiereceipt-edit +subjects: +- apiGroup: rbac.authorization.k8s.io + kind: Group + name: system:authenticated:oauth diff --git a/cookieprocessor-sa.yaml b/cookieprocessor-sa.yaml new file mode 100644 index 0000000..f1eec0b --- /dev/null +++ b/cookieprocessor-sa.yaml @@ -0,0 +1,19 @@ +--- +apiVersion: v1 +kind: ServiceAccount +metadata: + creationTimestamp: null + name: cookieprocessor +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: cookiereceipt-view +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: cookiereceipt-view +subjects: +- apiGroup: rbac.authorization.k8s.io + kind: ServiceAccount + name: cookieprocessor diff --git a/receipt-processor.ksh b/receipt-processor.ksh new file mode 100644 index 0000000..c752dd5 --- /dev/null +++ b/receipt-processor.ksh @@ -0,0 +1,116 @@ +#!/usr/bin/ksh +# by Olaf Bohlen +# licensed under BSD3 license + +APIURL="https://${KUBERNETES_SERVICE_HOST}:${KUBERNETES_SERVICE_PORT_HTTPS}" +NAMESPACE=$(- + An easy chocolate chip cookie recipe for soft biscuits with a + squidgy middle that will impress family and friends. Make plenty + as they're sure to be a hit. + source: https://www.bbcgoodfood.com/recipes/vintage-chocolate-chip-cookies + temperature: 190 + sanescale: true + preheat: true + duration: 8 + ingredients: + - name: salted butter + amount: 150 + unit: grams + remarks: softened + - name: light brown muscovado sugar + amount: 80 + unit: grams + - name: granulated sugar + amount: 80 + unit: grams + - name: vanilla extract + amount: 2 + unit: tea spoons + - name: egg + amount: 1 + unit: pieces + remarks: large + - name: plain flour + amount: 225 + unit: grams + - name: bicarbonate of soda + amount: 0.5 + unit: tea spoons + - name: salt + amount: 0.25 + unit: tea spoons + - name: plain chocolate chips + amount: 200 + unit: grams + remarks: or cut chocolate into small chunks + steps: + - order: 1 + instruction: Heat the oven and line two baking sheets with non-stick baking paper. + - order: 2 + instruction: Put 150g softened salted butter, 80g light brown muscovado sugar and 80g granulated sugar into a bowl and beat until creamy. + - order: 3 + instruction: Beat in 2 tsp vanilla extract and 1 large egg. + - order: 4 + instruction: Sift 225g plain flour, ½ tsp bicarbonate of soda and ¼ tsp salt into the bowl and mix it in with a wooden spoon. + - order: 5 + instruction: Add 200g plain chocolate chips or chunks and stir well. + - order: 6 + instruction: Use a teaspoon to make small scoops of the mixture, spacing them well apart on the baking trays. This mixture should make about 30 cookies. + - order: 7 + instruction: Bake for 8–10 mins until they are light brown on the edges and still slightly soft in the centre if you press them. + - order: 8 + instruction: Leave on the tray for a couple of mins to set and then lift onto a cooling rack. +--- +apiVersion: de.eenfach.olbohlen/v1 +kind: CookieReceipt +metadata: + name: double-dipped-shortbread +spec: + description: >- + What could be better than shortbread biscuits? Shortbread double-dipped in milk + and white chocolate! They are sure to go down a storm with family and friends + source: https://www.bbcgoodfood.com/recipes/double-dipped-shortbread-cookies + temperature: 180 + sanescale: true + preheat: true + duration: 8 + ingredients: + - name: salted butter + amount: 200 + unit: grams + remarks: softened + - name: icing sugar + amount: 100 + unit: grams + - name: vanilla extract + amount: 1 + unit: tea spoons + - name: plain flour + amount: 250 + unit: grams + - name: milk + amount: 1 + unit: table spoons + remarks: plus extra if needed + - name: white chocolate + amount: 50 + unit: grams + remarks: chopped + - name: milk chocolate + amount: 50 + unit: grams + remarks: chopped + steps: + - order: 1 + instruction: >- + Heat the oven to 180C/160C fan/gas 4. Beat the butter with the icing sugar using an electric whisk until the mixture is light and fluffy. Beat in the vanilla and flour (the mixture will stiffen and look like crumble as the flour is added). Add the milk and keep beating until the mixture softens and sticks together (add some more milk if needed). + - order: 2 + instruction: >- + Scoop the dough into a piping bag fitted with a large star nozzle and pipe swirled rings onto a baking sheet lined with baking parchment. If the mixture is too stiff to pipe easily, you can roll the dough into balls and put them on the sheet instead. The cookies will spread as they cook so don’t worry if there’s a small gap in the centre of the piped swirls, but ensure there is enough space between each cookie so they don’t stick together as they cook. Bake for 15 mins, or until lightly golden, then transfer to a wire rack to cool. + - order: 3 + instruction: >- + Put the white and milk chocolate in separate bowls and microwave each in 20-second bursts until melted. Dip the cookies into each chocolate, milk at one end and white on the other, then let any excess drip off before returning them to the rack to set. Will keep in an airtight tin for up to four days.