Skip to content

Commit

Permalink
docs: :rocket first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
karl-cardenas-coding committed Jan 22, 2024
1 parent 76bf391 commit 2003369
Show file tree
Hide file tree
Showing 33 changed files with 1,274 additions and 2 deletions.
15 changes: 15 additions & 0 deletions .copywrite.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
schema_version = 1

project {
copyright_holder = "Spectro Cloud"
license = "Apache-2.0"
copyright_year = 2024

# (OPTIONAL) A list of globs that should not have copyright/license headers.
# Supports doublestar glob patterns for more flexibility in defining which
# files or folders should be ignored
header_ignore = [
# "vendors/**",
# "**autogen**",
]
}
9 changes: 9 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
## Describe the Change

This PR .....

## Checklist

- [ ] README updated?

- [ ] Content added contain comments that explain the purpose of the script and usage?
36 changes: 36 additions & 0 deletions .github/workflows/gitleaks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: GitLeaks
on: [pull_request]

concurrency:
group: gitleaks-${{ github.ref }}
cancel-in-progress: true

jobs:
gitleaks-scan:
runs-on: ubuntu-latest
container:
image: gcr.io/spectro-dev-public/bulwark/gitleaks:latest
env:
REPO: ${{ github.event.repository.name }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITLEAKS_CONFIG: config.toml
steps:

- name: run-bulwark-gitleaks-scan
shell: sh
env:
BRANCH: ${{ github.head_ref || github.ref_name }}
run: /workspace/bulwark -name CodeSASTGitLeaks -target $REPO -tags "branch:$BRANCH,options:--log-opts origin..HEAD"

- name: check-result
shell: sh
run: |
resultPath=./$REPO/gitleaks.json
cat $resultPath | grep -v \"Match\"\: | grep -v \"Secret\"\:
total_failed_tests=`cat $resultPath | grep \"Fingerprint\"\: | wc -l`
if [ "$total_failed_tests" -gt 0 ]; then
echo "GitLeaks validation check failed with above findings..."
exit 1
else
echo "GitLeaks validation check passed"
fi
1 change: 1 addition & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @spectrocloud/education-engineers
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.PHONY: license

license:
@echo "Applying license headers..."
copywrite headers
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,13 @@
# palette-samples
A repository that contains templates, scripts, and other other useful content
# Palette Samples

![Spectro Cloud logo with docs inline](/static/images/spectrocloud-logo-light.svg)

This repository contains a collection of patterns, code samples, and more to help you get started with Palette and VerteX. Check out the resources below to learn more.

## Patterns

- [Managing Cluster Profiles with Terraform](./terraform/cluster-profiles/README.md)

## Contact Us

If you have any questions, please reach out to us at [[email protected]](mailto:[email protected]) or join our [Slack community](https://spectrocloudcommunity.slack.com).
21 changes: 21 additions & 0 deletions static/images/spectrocloud-logo-light.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions terraform/cluster-profiles/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Cluster Profile Management Patterns

This folder contains examples of how to manage cluster profiles using Terraform. There are multiple ways to manage cluster profiles using Terraform. The examples in this folder are meant to be used as a starting point for managing cluster profiles using Terraform. Use these examples as a reference and modify them to suit your needs.


Check out the READMEs in each folder to learn more about the different patterns.

- [Basic Pattern](./basic/README.md)

- [Intermediate Pattern](./cp-versions/README.md)

- [Advanced Pattern](./cp-profiles-with-module/README.md)
44 changes: 44 additions & 0 deletions terraform/cluster-profiles/basic/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

89 changes: 89 additions & 0 deletions terraform/cluster-profiles/basic/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# Basic Pattern

The basic pattern of managing and maintain cluster profiles. Each cluster profile version is defined through the `spectrocloud_cluster_profile` resource.


| Pros |
| ---- |
| Easy to understand |
| Easy to implement |
| Mimumum complexity |
| Profiles are clearly defined |
| Low chances of accidental changes |
| YAML customization supported through dedicated `pack {}` block |

| Cons |
| ---- |
| Requires code duplications |
| Tedious to maintain |


## Usage

1. Create a data resource for each pack. Replace the name of the pack with the name of the pack you are adding. For example, if you are adding the `csi-aws-ebs` pack, the data resource would look like the following:

```hcl
data "spectrocloud_pack" "csi-aws-ebs" {
name = "csi-aws-ebs"
version = "1.22.0"
registry_uid = data.spectrocloud_registry.public_registry.id
}
```

2. If adding a new pack version, add a new data resource for the pack.

```hcl
data "spectrocloud_pack" "csi-aws-ebs-1-24" {
name = "csi-aws-ebs"
version = "1.24.0"
registry_uid = data.spectrocloud_registry.public_registry.id
}
```


3. In the cluster profile resource `spectrocloud_cluster_profile`, add a new `pack {}` block for each pack version. Assign a name and version to the cluster profile.

```hcl
resource "spectrocloud_cluster_profile" "aws-profile-1-0-0" {
name = "tf-aws-profile"
description = "A basic cluster profile for AWS"
tags = concat(var.tags, ["env:aws", "version:1.0.0"])
cloud = "aws"
type = "cluster"
version = "1.0.0"
pack {
name = data.spectrocloud_pack.ubuntu-aws.name
tag = data.spectrocloud_pack.ubuntu-aws.version
uid = data.spectrocloud_pack.ubuntu-aws.id
values = data.spectrocloud_pack.ubuntu-aws.values
}
pack {
name = data.spectrocloud_pack.kubernetes.name
tag = data.spectrocloud_pack.kubernetes.version
uid = data.spectrocloud_pack.kubernetes.id
values = data.spectrocloud_pack.kubernetes.values
}
pack {
name = data.spectrocloud_pack.cni-calico.name
tag = data.spectrocloud_pack.cni-calico.version
uid = data.spectrocloud_pack.cni-calico.id
values = data.spectrocloud_pack.cni-calico.values
}
pack {
name = data.spectrocloud_pack.csi-aws-ebs.name
tag = data.spectrocloud_pack.csi-aws-ebs.version
uid = data.spectrocloud_pack.csi-aws-ebs.id
values = data.spectrocloud_pack.csi-aws-ebs.values
}
}
```

4. Repeat the above steps for each cluster profile version.


5. Reference the desired cluster profile in the `spectrocloud_cluster` resource.
78 changes: 78 additions & 0 deletions terraform/cluster-profiles/basic/cluster-profile.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Copyright (c) Spectro Cloud
# SPDX-License-Identifier: Apache-2.0

resource "spectrocloud_cluster_profile" "aws-profile-1-0-0" {

name = "tf-aws-profile"
description = "A basic cluster profile for AWS"
tags = concat(var.tags, ["env:aws", "version:1.0.0"])
cloud = "aws"
type = "cluster"
version = "1.0.0"

pack {
name = data.spectrocloud_pack.ubuntu-aws.name
tag = data.spectrocloud_pack.ubuntu-aws.version
uid = data.spectrocloud_pack.ubuntu-aws.id
values = data.spectrocloud_pack.ubuntu-aws.values
}

pack {
name = data.spectrocloud_pack.kubernetes.name
tag = data.spectrocloud_pack.kubernetes.version
uid = data.spectrocloud_pack.kubernetes.id
values = data.spectrocloud_pack.kubernetes.values
}

pack {
name = data.spectrocloud_pack.cni-calico.name
tag = data.spectrocloud_pack.cni-calico.version
uid = data.spectrocloud_pack.cni-calico.id
values = data.spectrocloud_pack.cni-calico.values
}

pack {
name = data.spectrocloud_pack.csi-aws-ebs.name
tag = data.spectrocloud_pack.csi-aws-ebs.version
uid = data.spectrocloud_pack.csi-aws-ebs.id
values = data.spectrocloud_pack.csi-aws-ebs.values
}
}

resource "spectrocloud_cluster_profile" "aws-profile-1-0-1" {

name = "tf-aws-profile"
description = "A basic cluster profile for AWS"
tags = concat(var.tags, ["env:aws", "version:1.0.1"])
cloud = "aws"
type = "cluster"
version = "1.0.1"

pack {
name = data.spectrocloud_pack.ubuntu-aws.name
tag = data.spectrocloud_pack.ubuntu-aws.version
uid = data.spectrocloud_pack.ubuntu-aws.id
values = data.spectrocloud_pack.ubuntu-aws.values
}

pack {
name = data.spectrocloud_pack.kubernetes.name
tag = data.spectrocloud_pack.kubernetes.version
uid = data.spectrocloud_pack.kubernetes.id
values = data.spectrocloud_pack.kubernetes.values
}

pack {
name = data.spectrocloud_pack.cni-calico.name
tag = data.spectrocloud_pack.cni-calico.version
uid = data.spectrocloud_pack.cni-calico.id
values = data.spectrocloud_pack.cni-calico.values
}

pack {
name = data.spectrocloud_pack.csi-aws-ebs-1-24.name
tag = data.spectrocloud_pack.csi-aws-ebs-1-24.version
uid = data.spectrocloud_pack.csi-aws-ebs-1-24.id
values = data.spectrocloud_pack.csi-aws-ebs-1-24.values
}
}
37 changes: 37 additions & 0 deletions terraform/cluster-profiles/basic/data.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Copyright (c) Spectro Cloud
# SPDX-License-Identifier: Apache-2.0

data "spectrocloud_registry" "public_registry" {
name = "Public Repo"
}


data "spectrocloud_pack" "csi-aws-ebs" {
name = "csi-aws-ebs"
version = "1.22.0"
registry_uid = data.spectrocloud_registry.public_registry.id
}

data "spectrocloud_pack" "csi-aws-ebs-1-24" {
name = "csi-aws-ebs"
version = "1.24.0"
registry_uid = data.spectrocloud_registry.public_registry.id
}

data "spectrocloud_pack" "cni-calico" {
name = "cni-calico"
version = "3.26.1"
registry_uid = data.spectrocloud_registry.public_registry.id
}

data "spectrocloud_pack" "kubernetes" {
name = "kubernetes"
version = "1.27.5"
registry_uid = data.spectrocloud_registry.public_registry.id
}

data "spectrocloud_pack" "ubuntu-aws" {
name = "ubuntu-aws"
version = "22.04"
registry_uid = data.spectrocloud_registry.public_registry.id
}
12 changes: 12 additions & 0 deletions terraform/cluster-profiles/basic/inputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright (c) Spectro Cloud
# SPDX-License-Identifier: Apache-2.0

variable "tags" {
type = list(string)
description = "The default tags to apply to Palette resources"
default = [
"spectro-cloud-education",
"repository:spectrocloud:tutorials",
"terraform_managed:true",
]
}
21 changes: 21 additions & 0 deletions terraform/cluster-profiles/basic/provider.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright (c) Spectro Cloud
# SPDX-License-Identifier: Apache-2.0

terraform {
required_providers {
spectrocloud = {
version = ">= 0.17.2"
source = "spectrocloud/spectrocloud"
}
local = {
source = "hashicorp/local"
version = ">= 2.4.0"
}
}

required_version = ">= 1.5"
}

provider "spectrocloud" {
project_name = "Default"
}
Loading

0 comments on commit 2003369

Please sign in to comment.