1 | # pk-template
|
2 | p template engine for kubernetes.
|
3 | this is proof of concept project for kubernetes yaml templating influenced by helm, css, jquery.
|
4 |
|
5 | ## install
|
6 | ```
|
7 | $ npm install pk-template -g
|
8 | ```
|
9 |
|
10 | ## example
|
11 | ```bash
|
12 | $ cat > pod.yaml <<EOF
|
13 | apiVersion: v1
|
14 | kind: Pod
|
15 | spec:
|
16 | containers:
|
17 | - image: <<<= image >>>
|
18 | EOF
|
19 |
|
20 | $ pkt pod.yaml --image nginx
|
21 | apiVersion: v1
|
22 | kind: Pod
|
23 | spec:
|
24 | containers:
|
25 | - image: nginx
|
26 | ```
|
27 |
|
28 | ```bash
|
29 | $ cat > sample.pkt <<EOF
|
30 | input:
|
31 | namespace: test
|
32 | routine:
|
33 | - assign:
|
34 | image: nginx
|
35 | - include: pod.yaml
|
36 | - assign:
|
37 | image: apache
|
38 | - include: pod.yaml
|
39 | - script: |
|
40 | for obj in $.objects
|
41 | obj.metadata =
|
42 | name: obj.spec.containers[0].image.split(':')[0].split('/')[*-1*]
|
43 | namespace: namespace
|
44 | EOF
|
45 | $ pkt sample.pkt --namespace pkt
|
46 | apiVersion: v1
|
47 | kind: Pod
|
48 | spec:
|
49 | containers:
|
50 | - image: nginx
|
51 | metadata:
|
52 | name: nginx
|
53 | namespace: pkt
|
54 | ---
|
55 | apiVersion: v1
|
56 | kind: Pod
|
57 | spec:
|
58 | containers:
|
59 | - image: apache
|
60 | metadata:
|
61 | name: apache
|
62 | namespace: pkt
|
63 |
|
64 | ```
|
65 |
|
66 | ## more info
|
67 | - [QuickStarts](quickstarts/QuickStarts.md)
|
68 |
|