Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add cluster update tutorial DOC-920 #28

Merged
merged 1 commit into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ env:
PALETTE_VERSION: 4.0.2
PALETTE_CLI_VERSION: 4.0.1
PALETTE_EDGE_VERSION: 3.4.3

PACKER_VERSION: 1.9.4
ORAS_VERSION: 1.0.0
TERRAFORM_VERSION: 1.6.5


jobs:
Expand Down Expand Up @@ -66,6 +68,9 @@ jobs:
PALETTE_VERSION=${{env.PALETTE_VERSION}}
PALETTE_CLI_VERSION=${{env.PALETTE_CLI_VERSION}}
PALETTE_EDGE_VERSION=${{env.PALETTE_EDGE_VERSION}}
PACKER_VERSION=${{env.PACKER_VERSION}}
ORAS_VERSION=${{env.ORAS_VERSION}}
TERRAFORM_VERSION=${{env.TERRAFORM_VERSION}}
platforms: linux/amd64,linux/arm64
push: true
tags: ghcr.io/${{ github.repository }}:${{steps.dependencies.outputs.VERSION}}
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ env:
PALETTE_VERSION: 4.0.2
PALETTE_CLI_VERSION: 4.0.1
PALETTE_EDGE_VERSION: 3.4.3
PACKER_VERSION: 1.9.4
ORAS_VERSION: 1.0.0
TERRAFORM_VERSION: 1.6.5

concurrency:
group: docker-${{ github.ref }}
Expand Down Expand Up @@ -73,5 +76,8 @@ jobs:
PALETTE_VERSION=${{env.PALETTE_VERSION}}
PALETTE_CLI_VERSION=${{env.PALETTE_CLI_VERSION}}
PALETTE_EDGE_VERSION=${{env.PALETTE_EDGE_VERSION}}
PACKER_VERSION=${{env.PACKER_VERSION}}
ORAS_VERSION=${{env.ORAS_VERSION}}
TERRAFORM_VERSION=${{env.TERRAFORM_VERSION}}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@ override.tf.json
my.*.tfvars
.terraform.lock.hcl
*.env

*.kubeconfig

12 changes: 8 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ ADD static/defaults/registry-config.yml etc/spectro/config.yml

ARG PALETTE_CLI_VERSION
ARG PALETTE_EDGE_VERSION
ARG PACKER_VERSION=1.9.4
ARG ORAS_VERSION=1.0.0
ARG PACKER_VERSION
ARG ORAS_VERSION
ARG TERRAFORM_VERSION

ENV REGISTRY_LOG_LEVEL=info
ENV REGISTRY_AUTH=htpasswd
Expand All @@ -30,7 +31,7 @@ COPY --from=server /etc/spectro/config.yml /etc/spectro/config.yml

RUN adduser -H -u 1002 -D appuser appuser && \
apk update && \
apk add --no-cache bash curl git terraform openssl jq bind-tools wget ca-certificates nano aws-cli xorriso govc
apk add --no-cache bash curl git openssl jq bind-tools wget ca-certificates nano aws-cli xorriso govc podman

RUN wget https://software.spectrocloud.com/spectro-registry/cli/v$PALETTE_CLI_VERSION/linux/spectro && \
mv spectro /usr/local/bin/spectro && \
Expand All @@ -57,7 +58,10 @@ RUN wget https://software.spectrocloud.com/spectro-registry/cli/v$PALETTE_CLI_V
mv oras-install/oras /usr/local/bin/ && \
rm -rf oras_${ORAS_VERSION}_*.tar.gz oras-install/ && \
git clone https://github.com/spectrocloud/CanvOS.git && \
rm -rf /var/cache/apk/*
rm -rf /var/cache/apk/* && \
wget https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip && \
unzip terraform_${TERRAFORM_VERSION}_linux_amd64.zip -d /usr/local/bin && \
rm -rf terraform_${TERRAFORM_VERSION}_linux_amd64.zip

ADD https://releases.hashicorp.com/packer/${PACKER_VERSION}/packer_${PACKER_VERSION}_linux_amd64.zip /usr/local/sbin/
RUN unzip /usr/local/sbin/packer_${PACKER_VERSION}_linux_amd64.zip -d /usr/local/sbin && \
Expand Down
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,10 @@ help: ## Display this help

build-docker: ## Build docker image
@echo "Building docker image"
docker build --build-arg PALETTE_VERSION=$(VERSION) --build-arg PALETTE_CLI_VERSION=$(VERSION) --build-arg PALETTE_EDGE_VERSION=$(EDGE) --build-arg PACKER_VERSION=1.8.7 -t tutorials .
docker build --build-arg PALETTE_VERSION=$(PALETTE_VERSION) \
--build-arg PALETTE_CLI_VERSION=$(PALETTE_CLI_VERION) \
--build-arg PALETTE_EDGE_VERSION=$(PALETTE_EDGE_VERSION) \
--build-arg PACKER_VERSION=$(PACKER_VERSION) \
--build-arg ORAS_VERSION=$(PACKER_VERSION) \
--build-arg TERRAFORM_VERSION=$(TERRAFORM_VERSION) \
-t tutorials .
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ The following tutorial code is available:

- [terraform-cluster-deployment-tf](./terraform/iaas-cluster-deployment-tf/README.md) - Learn how to deploy a cluster to a cloud provider with Palette. [Link](https://docs.spectrocloud.com/clusters/public-cloud/deploy-k8s-cluster)

- [terraform-cluster-update-tf](./terraform/iaas-cluster-update-tf/README.md) - Learn how to update a cluster deployed to a cloud provider with Palette. [Link](https://docs.spectrocloud.com/clusters/cluster-management/update-k8s-cluster)

- [Deploy an Edge cluster on VMware](./edge/vmware/README.md) - Learn how to deploy an Edge cluster on VMware. [Link](https://docs.spectrocloud.com/clusters/edge/site-deployment/deploy-cluster)

## Docker
Expand Down
9 changes: 5 additions & 4 deletions docs/docker.md
addetz marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
To download the image issue the following commnad. Change the version tag as needed.

```shell
docker pull ghcr.io/spectrocloud/tutorials:1.0.2
docker pull ghcr.io/spectrocloud/tutorials:1.0.12
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bumping to current version+1 as this will be a new release

```

You can start the container using the following command.

```shell
docker run -p 5000:5000 --rm -it ghcr.io/spectrocloud/tutorials:1.0.2 bash
docker run -p 5000:5000 --rm -it ghcr.io/spectrocloud/tutorials:1.0.12 bash
```


Expand Down Expand Up @@ -42,6 +42,7 @@ The Docker image includes the following tools.
| `GOVC` | Tool for interracting with VMware Vsphere via API |
| `aws-cli` | AWS command-line interface |
| `oras` | Tool for pushing and pulling OCI artifacts to and from OCI registries|
| `podman` | Tool for building and deploying OCI images |

### Spectro Cloud Pack Registry Server

Expand All @@ -61,9 +62,9 @@ registry serve /etc/spectro/config.yml > /var/log/registry.log 2>&1 &

# Local Builds

If you are wanting to build the docker image locally you must provide the the build arguments for `PALETTE_VERSION` and `PALETTE_CLI_VERSION`, `PALETTE_EDGE_VERSION`. Use the following command to build a local image. Replace the versions as needed.
If you are wanting to build the docker image locally you must provide the the build arguments for `PALETTE_VERSION`, `PALETTE_CLI_VERSION`, `PALETTE_EDGE_VERSION`, `PACKER_VERSION`, `ORAS_VERSION` and `TERRAFORM_VERSION`. Use the following command to build a local image. Replace the versions as needed.


```shell
docker build --build-arg PALETTE_VERSION=4.0.2 --build-arg PALETTE_CLI_VERSION=4.0.1 --build-arg PALETTE_EDGE_VERSION=3.4.3 --build-arg PACKER_VERSION=1.9.4 -t tutorials .
docker build --build-arg PALETTE_VERSION=4.0.2 --build-arg PALETTE_CLI_VERSION=4.0.1 --build-arg PALETTE_EDGE_VERSION=3.4.3 --build-arg PACKER_VERSION=1.9.4 --build-arg ORAS_VERSION=1.0.0 --build-arg TERRAFORM_VERSION=1.6.5 -t tutorials .
```
7 changes: 4 additions & 3 deletions terraform/iaas-cluster-deployment-tf/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ To get started, open up the file **terraform.tfvars**. Toggle the provider varia

| Name | Version |
|------|---------|
| <a name="provider_spectrocloud"></a> [spectrocloud](#provider\_spectrocloud) | 0.13.1 |
| <a name="provider_spectrocloud"></a> [spectrocloud](#provider\_spectrocloud) | 0.16.1 |
| <a name="provider_tls"></a> [tls](#provider\_tls) | 4.0.4 |

## Modules
Expand All @@ -39,7 +39,7 @@ No modules.
| Name | Type |
|------|------|
| [spectrocloud_cluster_aws.aws-cluster](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/resources/cluster_aws) | resource |
| [spectrocloud_cluster_azure.cluster](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/resources/cluster_azure) | resource |
| [spectrocloud_cluster_azure.azure-cluster](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/resources/cluster_azure) | resource |
| [spectrocloud_cluster_gcp.gcp-cluster](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/resources/cluster_gcp) | resource |
| [spectrocloud_cluster_profile.aws-profile](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/resources/cluster_profile) | resource |
| [spectrocloud_cluster_profile.azure-profile](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/resources/cluster_profile) | resource |
Expand Down Expand Up @@ -68,11 +68,12 @@ No modules.
|------|-------------|------|---------|:--------:|
| <a name="input_aws-cloud-account-name"></a> [aws-cloud-account-name](#input\_aws-cloud-account-name) | The name of your AWS account as assigned in Palette | `string` | `""` | no |
| <a name="input_aws-key-pair-name"></a> [aws-key-pair-name](#input\_aws-key-pair-name) | The name of the AWS key pair to use for SSH access to the cluster. Refer to [EC2 Key Pairs](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-key-pairs.html) to learn more. | `string` | `""` | no |
| <a name="input_aws-region"></a> [aws-region](#input\_aws-region) | AWS region | `string` | n/a | yes |
| <a name="input_aws-region"></a> [aws-region](#input\_aws-region) | AWS region | `string` | `"us-east-1"` | yes |
| <a name="input_aws_master_nodes"></a> [aws\_master\_nodes](#input\_aws\_master\_nodes) | AWS master nodes configuration. | <pre>object({<br> count = string<br> control_plane = bool<br> instance_type = string<br> disk_size_gb = string<br> availability_zones = list(string)<br> })</pre> | <pre>{<br> "availability_zones": [<br> "us-east-1a"<br> ],<br> "control_plane": true,<br> "count": "1",<br> "disk_size_gb": "60",<br> "instance_type": "m4.2xlarge"<br>}</pre> | no |
| <a name="input_aws_worker_nodes"></a> [aws\_worker\_nodes](#input\_aws\_worker\_nodes) | AWS worker nodes configuration. | <pre>object({<br> count = string<br> control_plane = bool<br> instance_type = string<br> disk_size_gb = string<br> availability_zones = list(string)<br> })</pre> | <pre>{<br> "availability_zones": [<br> "us-east-1a"<br> ],<br> "control_plane": false,<br> "count": "1",<br> "disk_size_gb": "60",<br> "instance_type": "m4.2xlarge"<br>}</pre> | no |
| <a name="input_azure-cloud-account-name"></a> [azure-cloud-account-name](#input\_azure-cloud-account-name) | The name of your Azure account as assigned in Palette | `string` | `""` | no |
| <a name="input_azure-region"></a> [azure-region](#input\_azure-region) | Azure region | `string` | `"eastus"` | no |
| <a name="input_azure-use-azs"></a> [azure-use-azs](#input\_azure-use-azs) | A flag for configuring whether to use Azure Availability Zones. Check if your Azure region supports availability zones by reviewing the [Azure Regions and Availability Zones](https://learn.microsoft.com/en-us/azure/reliability/availability-zones-service-support#azure-regions-with-availability-zone-support) resource. | `bool` | `true` | no |
| <a name="input_azure_master_nodes"></a> [azure\_master\_nodes](#input\_azure\_master\_nodes) | Azure master nodes configuration. | <pre>object({<br> count = string<br> control_plane = bool<br> instance_type = string<br> disk_size_gb = string<br> azs = list(string)<br> is_system_node_pool = bool<br> })</pre> | <pre>{<br> "azs": [<br> "1"<br> ],<br> "control_plane": true,<br> "count": "1",<br> "disk_size_gb": "60",<br> "instance_type": "Standard_A8_v2",<br> "is_system_node_pool": false<br>}</pre> | no |
| <a name="input_azure_resource_group"></a> [azure\_resource\_group](#input\_azure\_resource\_group) | Azure resource group | `string` | `""` | no |
| <a name="input_azure_subscription_id"></a> [azure\_subscription\_id](#input\_azure\_subscription\_id) | Azure subscription ID | `string` | `""` | no |
Expand Down
2 changes: 1 addition & 1 deletion terraform/iaas-cluster-deployment-tf/clusters.tf
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ resource "spectrocloud_cluster_aws" "aws-cluster" {
#########################
# Azure Cluster Profile
#########################
resource "spectrocloud_cluster_azure" "cluster" {
resource "spectrocloud_cluster_azure" "azure-cluster" {
count = var.deploy-azure ? 1 : 0

name = "azure-cluster"
Expand Down
85 changes: 53 additions & 32 deletions terraform/iaas-cluster-deployment-tf/data.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
####################################
# Data resources for the profile
####################################
data "spectrocloud_registry" "public_registry" {
name = "Public Repo"
}

#############
# AWS
#############
Expand All @@ -7,20 +14,27 @@ data "spectrocloud_cloudaccount_aws" "account" {
}

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

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

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

data "spectrocloud_pack" "aws_ubuntu" {
name = "ubuntu-aws"
version = "20.04"
name = "ubuntu-aws"
version = "22.04"
registry_uid = data.spectrocloud_registry.public_registry.id
}

#############
Expand All @@ -32,21 +46,29 @@ data "spectrocloud_cloudaccount_azure" "account" {
}

data "spectrocloud_pack" "azure_csi" {
name = "csi-azure"
version = "1.25.0"
name = "csi-azure"
version = "1.28.3"
registry_uid = data.spectrocloud_registry.public_registry.id
}

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

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

data "spectrocloud_pack" "azure_ubuntu" {
name = "ubuntu-azure"
version = "20.04"
name = "ubuntu-azure"
version = "22.04"
registry_uid = data.spectrocloud_registry.public_registry.id
}

#############
# GCP
#############
Expand All @@ -56,26 +78,25 @@ data "spectrocloud_cloudaccount_gcp" "account" {
}

data "spectrocloud_pack" "gcp_csi" {
name = "csi-gcp-driver"
version = "1.7.1"
name = "csi-gcp-driver"
version = "1.8.2"
registry_uid = data.spectrocloud_registry.public_registry.id
}

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

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

data "spectrocloud_pack" "gcp_ubuntu" {
name = "ubuntu-gcp"
version = "20.04"
name = "ubuntu-gcp"
version = "22.04"
registry_uid = data.spectrocloud_registry.public_registry.id
}
#############
# Universal
#############

data "spectrocloud_pack" "proxy" {
name = "spectro-proxy"
version = "1.3.0"
}
8 changes: 7 additions & 1 deletion terraform/iaas-cluster-deployment-tf/inputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,15 @@ variable "azure_resource_group" {
default = ""
}

variable "azure-use-azs" {
type = bool
description = "A flag for configuring whether to use Azure Availability Zones. Check if your Azure region supports availability zones by reviewing the [Azure Regions and Availability Zones](https://learn.microsoft.com/en-us/azure/reliability/availability-zones-service-support#azure-regions-with-availability-zone-support) resource"
}

variable "aws-region" {
type = string
description = "AWS region"
default = "us-east-1"
}

variable "gcp-region" {
Expand Down Expand Up @@ -139,7 +145,7 @@ variable "azure_worker_nodes" {
control_plane = false
instance_type = "Standard_A8_v2"
disk_size_gb = "60"
azs = []
azs = ["1"]
is_system_node_pool = false }
description = "Azure worker nodes configuration."
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
apiVersion: v1
kind: Namespace
metadata:
name: hello-universe
---
apiVersion: v1
kind: Service
metadata:
name: hello-universe-service
namespace: hello-universe
spec:
type: LoadBalancer
selector:
app: hello-universe
ports:
- protocol: TCP
port: 8080
targetPort: 8080
selector:
app: hello-universe
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: hello-universe-deployment
namespace: hello-universe
spec:
replicas: 2
selector:
Expand All @@ -27,7 +34,7 @@ spec:
spec:
containers:
- name: hello-universe
image: ghcr.io/spectrocloud/hello-universe:1.0.12
image: ghcr.io/spectrocloud/hello-universe:1.1.0
imagePullPolicy: IfNotPresent
ports:
- containerPort: 8080
2 changes: 2 additions & 0 deletions terraform/iaas-cluster-deployment-tf/provider.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ terraform {
version = "4.0.4"
}
}

required_version = ">= 1.5"
}
provider "spectrocloud" {
project_name = "Default"
Expand Down
Loading
Loading