Skip to content

Commit

Permalink
fix: stacks page 404ing (#400)
Browse files Browse the repository at this point in the history
  • Loading branch information
nickcernera authored Feb 13, 2025
1 parent c3f10a2 commit ae949f8
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 79 deletions.
69 changes: 69 additions & 0 deletions pages/deployments/stacks.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,72 @@
title: Stacks
description: How to manage Infrastructure as Code at Scale Using Plural
---

The goal of Plural Stacks is to provide a scalable framework to manage infrastructure as code like Terraform, Ansible and Pulumi with a kubernetes-friendly, api-driven approach. The core workflow is as follows:

* Declaratively define a stack with a type (terraform, ansible, etc), a location in a git repository to source code from, and a cluster on which it will execute
* On each commit to the tracked git repository, a run is created which the Plural deployment operator will detect and execute on the targeted cluster
- this allows users to fine grain permissions and network location of IaC runs where both are necessary to configure.
* Plural will carefully execute the run for you, and besides basic information like communicating stdout to the UI, we will also gather and present useful information like inputs/outputs, terraform state diagrams and more
* On PRs to the tracked repository, a "plan" run is also executed and comments posted on the relevant PR where possible.

To get a better idea of the full power of the experience, feel free to take a look at this demo video (at 2x speed if you want to save some time):

{% embed url="https://youtu.be/06WXbvw6p3w" aspectRatio="16 / 9" /%}

# A Basic Stack

The most common way to instantiate a stack is via Kubernetes CRD. This gives a flexible, modular way of recreating infrastructure with Terraform and pairs nicely with our PR Automation tooling for full self-service around IaC.

Here's an example:

```yaml
apiVersion: deployments.plural.sh/v1alpha1
kind: InfrastructureStack
metadata:
name: gke-demo
namespace: stacks
spec:
name: gke-demo
type: TERRAFORM
approval: true
detach: false
manageState: true
actor: [email protected]
configuration:
version: 1.8.2
repositoryRef:
name: fleet
namespace: fleets
clusterRef:
name: mgmt
namespace: infra
workdir: gke-cluster
git:
ref: main
folder: terraform
files:
- mountPath: /plural
secretRef:
name: gcp-creds
environment:
- name: GOOGLE_APPLICATION_CREDENTIALS
value: /plural/creds.json
- name: TF_VAR_cluster
value: gke-demo
- name: TF_VAR_tier
value: dev
- name: TF_VAR_fleet
value: gke-dem
```
The meaning of this yaml is pretty self-documenting, we are:
* creating a `TERRAFORM` stack, so it will execute the standard terraform workflow
* we're using Plural as the state store, removing the need to configure S3 or other backends manually
* `approval` will be required before `terraform apply` will trigger, ensuring a human verifies the plan first to reduce misconfiguration risk
* we're sourcing manifests from the `fleet` repository (referencing a `GitRepository` crd)
* we're executing on the `mgmt` cluster (referencing a `Cluster` crd)
* and we're executing in the `terraform/gke-cluster` folder

You can also see you can bind files and environment variables into the environment, although it is still best practice to use IRSA, GKE workload identity or similar mechanisms for issuing cloud credentials.
73 changes: 0 additions & 73 deletions pages/stacks/overview.md

This file was deleted.

8 changes: 2 additions & 6 deletions src/NavData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,9 @@ const rootNavData: NavMenu = deepFreeze([
],
},
{
href: '/stacks/',
title: 'Iac Management with Stacks',
href: '/deployments/stacks/',
title: 'IaC Management with Stacks',
sections: [
{
title: 'Overview',
href: '/stacks/overview',
},
{
title: 'Customizing Stack Runners',
href: '/stacks/customize-runners',
Expand Down
1 change: 1 addition & 0 deletions src/generated/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3799,6 +3799,7 @@ export type RootQueryType = {
invoices?: Maybe<InvoiceConnection>;
keyBackup?: Maybe<KeyBackup>;
keyBackups?: Maybe<KeyBackupConnection>;
licenseKey?: Maybe<Scalars['String']['output']>;
loginMethod?: Maybe<LoginMethodResponse>;
loginMetrics?: Maybe<Array<Maybe<GeoMetric>>>;
me?: Maybe<User>;
Expand Down

0 comments on commit ae949f8

Please sign in to comment.