|
| 1 | +--- |
| 2 | +menu: |
| 3 | + learn: |
| 4 | + parent: Patterns quick start |
| 5 | +title: Creating a pattern with patternizer |
| 6 | +weight: 19 |
| 7 | +--- |
| 8 | + |
| 9 | +:toc: |
| 10 | +:imagesdir: /images |
| 11 | +:_content-type: ASSEMBLY |
| 12 | +include::modules/comm-attributes.adoc[] |
| 13 | + |
| 14 | +== Creating a new pattern with patternizer |
| 15 | + |
| 16 | +link:https://github.com/validatedpatterns/patternizer[Patternizer] is a command-line tool that bootstraps a Git repository into a ready-to-use Validated Pattern. It generates all required scaffolding -- values files, Makefile, `pattern.sh`, and Ansible configuration -- so you can focus on defining your applications rather than wiring up framework boilerplate. |
| 17 | + |
| 18 | +=== Prerequisites |
| 19 | + |
| 20 | +* A container runtime (Podman or Docker) |
| 21 | +* Git |
| 22 | + |
| 23 | +[TIP] |
| 24 | +.Shell Function |
| 25 | +==== |
| 26 | +You can add a simple shell function to your shell configuration file (for example `~/.zshrc` or `~/.bashrc`) to enable easier use of the tool. |
| 27 | +
|
| 28 | +[source,bash] |
| 29 | +---- |
| 30 | +pattern() { |
| 31 | + podman run --pull=newer \ |
| 32 | + -v "$PWD:$PWD:z" \ |
| 33 | + -w "$PWD" \ |
| 34 | + quay.io/validatedpatterns/patternizer "$@" |
| 35 | +} |
| 36 | +---- |
| 37 | +
|
| 38 | +With this function, you can run `pattern init` directly instead of the full `podman run` command. The examples below assume this function is in place. |
| 39 | +==== |
| 40 | + |
| 41 | +=== Step 1: Create your pattern repository |
| 42 | + |
| 43 | +Create or clone an empty Git repository named after your pattern. The directory name becomes the pattern name in `values-global.yaml`. |
| 44 | + |
| 45 | +[source,terminal] |
| 46 | +---- |
| 47 | +$ mkdir my-pattern && cd my-pattern |
| 48 | +$ git init |
| 49 | +---- |
| 50 | + |
| 51 | +=== Step 2: Initialize the pattern |
| 52 | + |
| 53 | +To create a pattern without the secrets framework: |
| 54 | + |
| 55 | +[source,terminal] |
| 56 | +---- |
| 57 | +$ pattern init |
| 58 | +---- |
| 59 | + |
| 60 | +To create a pattern with HashiCorp Vault and External Secrets Operator scaffolding: |
| 61 | + |
| 62 | +[source,terminal] |
| 63 | +---- |
| 64 | +$ pattern init --with-secrets |
| 65 | +---- |
| 66 | + |
| 67 | +==== What patternizer generates |
| 68 | + |
| 69 | +Running `pattern init --with-secrets` on an empty directory named `my-pattern` produces the following files: |
| 70 | + |
| 71 | +[source,bash] |
| 72 | +---- |
| 73 | +my-pattern |
| 74 | +├── ansible.cfg # default Ansible configuration |
| 75 | +├── Makefile # stub Makefile which includes Makefile-common |
| 76 | +├── Makefile-common # common commands (install, load-secrets, etc.) |
| 77 | +├── pattern.sh # convenience utility container (has oc, helm, make, etc.) |
| 78 | +├── values-global.yaml # names the pattern based on the directory and sets common defaults |
| 79 | +├── values-prod.yaml # contains the components for the secrets framework |
| 80 | +└── values-secret.yaml.template # stub for the secrets file |
| 81 | +---- |
| 82 | + |
| 83 | +The generated `values-global.yaml` contains: |
| 84 | + |
| 85 | +[source,yaml] |
| 86 | +---- |
| 87 | +global: |
| 88 | + pattern: my-pattern |
| 89 | + singleArgoCD: true |
| 90 | + secretLoader: |
| 91 | + disabled: false |
| 92 | +main: |
| 93 | + clusterGroupName: prod |
| 94 | + multiSourceConfig: |
| 95 | + enabled: true |
| 96 | + clusterGroupChartVersion: 0.9.* |
| 97 | +---- |
| 98 | + |
| 99 | +The generated `values-prod.yaml` contains: |
| 100 | + |
| 101 | +[source,yaml] |
| 102 | +---- |
| 103 | +clusterGroup: |
| 104 | + name: prod |
| 105 | + namespaces: |
| 106 | + my-pattern: |
| 107 | + vault: |
| 108 | + external-secrets-operator: |
| 109 | + operatorGroup: true |
| 110 | + targetNamespaces: [] |
| 111 | + external-secrets: |
| 112 | + subscriptions: |
| 113 | + eso: |
| 114 | + name: openshift-external-secrets-operator |
| 115 | + namespace: external-secrets-operator |
| 116 | + channel: stable-v1 |
| 117 | + applications: |
| 118 | + openshift-external-secrets: |
| 119 | + name: openshift-external-secrets |
| 120 | + namespace: external-secrets |
| 121 | + chart: openshift-external-secrets |
| 122 | + chartVersion: 0.0.* |
| 123 | + vault: |
| 124 | + name: vault |
| 125 | + namespace: vault |
| 126 | + chart: hashicorp-vault |
| 127 | + chartVersion: 0.1.* |
| 128 | +---- |
| 129 | + |
| 130 | +If you omit `--with-secrets`, the generated files will not include the Vault and External Secrets Operator configuration, and `secretLoader.disabled` will be set to `true` in `values-global.yaml`. |
| 131 | + |
| 132 | +=== Step 3: Define your pattern content |
| 133 | + |
| 134 | +After initialization, you need to add your operators, applications, and Helm charts to the pattern. There are two approaches: |
| 135 | + |
| 136 | +==== Using the pattern-author AI coding skill |
| 137 | + |
| 138 | +Patternizer installs an AI coding skill to `.claude/skills/pattern-author/` and `.cursor/skills/pattern-author/` during initialization. This skill teaches AI coding assistants such as Claude Code and Cursor how to author Validated Patterns -- defining namespaces, operators, applications, secrets, hub/spoke clusters, and more. |
| 139 | + |
| 140 | +Open the initialized repository in your AI-assisted editor and the skill will be available automatically. You can ask the assistant to add operators, wire in Helm charts, configure secrets, or set up multi-cluster deployments. |
| 141 | + |
| 142 | +==== Manually editing values files |
| 143 | + |
| 144 | +You can directly edit the generated values files to define your pattern: |
| 145 | + |
| 146 | +* Add operator subscriptions and namespaces to `values-prod.yaml` |
| 147 | +* Add Helm chart applications to `values-prod.yaml` |
| 148 | +* Configure global settings in `values-global.yaml` |
| 149 | +* Define secrets in `values-secret.yaml.template` |
| 150 | + |
| 151 | +For detailed guidance on structuring your pattern, see link:/learn/vp_structure_vp_pattern/[Structuring a validated pattern]. For adding operators, see link:/learn/vp_add_ops_to_pattern/[Adding operators to the framework]. |
| 152 | + |
| 153 | +[NOTE] |
| 154 | +.Idempotency |
| 155 | +==== |
| 156 | +The `pattern init` command is idempotent and can be run multiple times during pattern creation to update the pattern values files. You can go from `pattern init` to `pattern init --with-secrets` to add the secrets framework to your pattern. If you use `helm create` (or `./pattern.sh helm create`) to create Helm charts and then run `pattern init` again, the Helm charts will be automatically added to your `values-prod.yaml`. |
| 157 | +==== |
| 158 | + |
| 159 | +=== Next steps |
| 160 | + |
| 161 | +* Deploy an existing pattern like link:/learn/getting-started-multi-cloud-gitops/[Multicloud GitOps] to explore how the framework works in practice |
| 162 | +* Learn about link:/learn/vp_structure_vp_pattern/[structuring a validated pattern] and best practices |
| 163 | +* Add operators to your pattern with link:/learn/vp_add_ops_to_pattern/[Adding operators to the framework] |
| 164 | +* Configure secrets with link:/learn/getting-started-secret-management/[Configuring secrets] |
| 165 | +* Visit the link:https://github.com/validatedpatterns/patternizer[patternizer repository on GitHub] for the latest documentation |
0 commit comments