Skip to content

Commit

Permalink
Bump default image to 1.0.14; Add docs for deploying to fargate
Browse files Browse the repository at this point in the history
  • Loading branch information
AnchorArray committed Apr 10, 2024
1 parent 2d41ea9 commit 53081c2
Show file tree
Hide file tree
Showing 9 changed files with 308 additions and 5 deletions.
2 changes: 2 additions & 0 deletions charts/langkit/.helmignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@
.idea/
*.tmproj
.vscode/
# Documentation
docs/
7 changes: 6 additions & 1 deletion charts/langkit/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,18 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning]
(https://semver.org/spec/v2.0.0.html).

## [0.17.0] - 2024-04-10

### Changed

- Updated image from `1.0.13` to `1.0.14`

## [0.16.0] - 2024-03-28

### Changed

- Updated image from `1.0.11` to `1.0.13`


## [0.15.0] - 2024-03-22

### Added
Expand Down
4 changes: 2 additions & 2 deletions charts/langkit/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ apiVersion: v2
name: langkit
description: A Helm chart for LangKit container deployment
type: application
version: 0.16.0
appVersion: "1.0.13"
version: 0.17.0
appVersion: "1.0.14"
2 changes: 1 addition & 1 deletion charts/langkit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ helm-docs --dry-run
| image.containerPort | int | `8000` | |
| image.pullPolicy | string | `"Always"` | |
| image.repository | string | `"registry.gitlab.com/whylabs/langkit-container"` | |
| image.tag | string | `"1.0.13"` | |
| image.tag | string | `"1.0.14"` | |
| imagePullSecrets[0].name | string | `"langkit-gitlab-registry-secret"` | |
| ingress.annotations | object | `{}` | |
| ingress.className | string | `""` | |
Expand Down
94 changes: 94 additions & 0 deletions charts/langkit/docs/deploy-fargate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
#!/usr/bin/env bash

# Setting common bash options
set -o errexit # Exit on error
set -o nounset # Treat unset variables as an error
set -o pipefail # Consider errors in a pipeline

# Default values for configuration variables
cluster_name="whylabs"
aws_region="us-west-2"

# Function to print usage
usage() {
echo "Usage: $0 [--cluster-name <name>] [--aws-region <region>]"
exit 1
}

# Parse command line arguments
while [[ "$#" -gt 0 ]]; do
case $1 in
--cluster-name) cluster_name="$2"; shift ;;
--aws-region) aws_region="$2"; shift ;;
*) echo "Unknown parameter passed: $1"; exit 1 ;;
esac
shift
done

# Automatically determine the architecture
ARCH=$(uname -m)
case $ARCH in
x86_64)
ARCH=amd64
;;
aarch64 | arm64)
ARCH=arm64
;;
*)
echo "Unsupported architecture: $ARCH"
exit 1
;;
esac
PLATFORM=$(uname -s)_$ARCH

export AWS_REGION="${aws_region}"

# Install eksctl
curl -sLO "https://github.com/eksctl-io/eksctl/releases/latest/download eksctl_$PLATFORM.tar.gz"
tar -xzf eksctl_$PLATFORM.tar.gz -C /tmp && rm eksctl_$PLATFORM.tar.gz
sudo mv /tmp/eksctl /usr/local/bin

# Validate eksctl installation
if ! command -v eksctl &> /dev/null; then
echo "eksctl could not be installed"
exit 1
fi

# Install helm
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
chmod 700 get_helm.sh
./get_helm.sh

# Validate Helm installation
if ! command -v helm &> /dev/null; then
echo "Helm could not be installed"
exit 1
fi

# Create a configuration file for eksctl
cat <<EOF > cluster.yaml
apiVersion: eksctl.io/v1alpha5
kind: ClusterConfig
metadata:
name: "${cluster_name}"
region: "${aws_region}"
iam:
withOIDC: true
fargateProfiles:
- name: default
selectors:
- namespace: default
- namespace: kube-system
EOF

# Check if the configuration file exists
if [ ! -f cluster.yaml ]; then
echo "Configuration file not found; exiting"
exit 1
fi

# Create the cluster from the configuration file
eksctl create cluster -f cluster.yaml
101 changes: 101 additions & 0 deletions charts/langkit/docs/deploy-langkit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
#!/usr/bin/env bash

# Setting common bash options
set -o errexit # Exit on error
set -o nounset # Treat unset variables as an error
set -o pipefail # Consider errors in a pipeline

# Default values for configuration variables
whylabs_api_key=""
langkit_password=""
registry_username=""
registry_token=""
chart_version=""

# Function to print usage
usage() {
echo "Usage: $0 [--whylabs-api-key <key>] [--langkit-password <password>] [--registry-username <username>]"
echo " [--chart-version <version>] [--registry-token <token>]"
exit 1
}

# Parse command line arguments
while [[ "$#" -gt 0 ]]; do
case $1 in
--whylabs-api-key) whylabs_api_key="$2"; shift ;;
--langkit-password) langkit_password="$2"; shift ;;
--registry-username) registry_username="$2"; shift ;;
--registry-token) registry_token="$2"; shift ;;
--chart-version) chart_version="$2"; shift ;;
*) echo "Unknown parameter passed: $1"; exit 1 ;;
esac
shift
done

# Check mandatory parameters
if [ -z "$whylabs_api_key" ] || [ -z "$langkit_password" ] || [ -z "$registry_username" ] || [ -z "$registry_token" ] || [ -z "$chart_version" ]; then
echo "Error: Missing required parameters."
usage
fi

# Create Kubernetes secrets
kubectl create secret generic whylabs-api-key \
--namespace=langkit \
--from-literal=WHYLABS_API_KEY="${whylabs_api_key}"

# Verify the secret was created successfully
if [ $? -ne 0 ]; then
echo "whylabs-api-key secret creation failed; exiting"
exit 1
fi

kubectl create secret generic langkit-api-secret \
--namespace=langkit \
--from-literal=CONTAINER_PASSWORD="${langkit_password}"

# Verify the secret was created successfully
if [ $? -ne 0 ]; then
echo "langkit-api-secret secret creation failed; exiting"
exit 1
fi

kubectl create secret docker-registry langkit-gitlab-registry-secret \
--docker-server="registry.gitlab.com" \
--docker-username="${registry_username}" \
--docker-password="${registry_token}" \
--docker-email="${registry_username}@noreply.gitlab.com" \
--namespace=langkit

# Verify the secret was created successfully
if [ $? -ne 0 ]; then
echo "langkit-gitlab-registry-secret secret creation failed; exiting"
exit 1
fi

# Download the langkit Helm chart
helm pull \
oci://ghcr.io/whylabs/langkit \
--version "${chart_version}"

# Check if helm pull was successful
if [ $? -ne 0 ]; then
echo "Helm chart download failed; exiting"
exit 1
fi

# Verify the Helm chart file exists at the expected path
if [ ! -f "langkit-${chart_version}.tgz" ]; then
echo "Helm chart not found; exiting"
exit 1
fi

# Install the langkit Helm chart
helm upgrade --install \
--namespace default \
langkit "langkit-${chart_version}.tgz"

# Check if Helm chart installation was successful
if [ $? -ne 0 ]; then
echo "Helm chart installation failed; exiting"
exit 1
fi
57 changes: 57 additions & 0 deletions charts/langkit/docs/fargate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Fargate Deployment


This guide describes how to set up an EKS cluster using Fargate for deploying
Langkit. The process involves three separate scripts for better organization and
maintainability.

## Prerequisites

- An AWS account with appropriate permissions for EKS and Fargate.
- Git installed on your local machine.

## Steps

1. Clone this repository

```shell
git clone https://github.com/whylabs/charts.git

(
cd charts/langkit/docs
chmod 755 prepare.sh
chmod 755 deploy-fargate.sh
chmod 755 deploy-langkit.sh
)
```

1. Install dependencies

Navigate to the cloned directory and run the following command to install
`eksctl` and `helm` for managing EKS clusters and Helm charts:

```shell
./prepare.sh
```

1. Create EKS Fargate Cluster

This script creates an EKS cluster configured to use Fargate for pod execution.
By default, it creates a cluster named whylabs in the us-west-2 region:

```shell
./deploy-fargate.sh \
--cluster-name whylabs \
--aws-region us-west-2
```

1. Deploy Langkit

```shell
./deploy-langkit.sh \
--whylabs_api_key <key> \
--langkit_password <password> \
--registry_username <username> \
--registry_token <token> \
--chart_version <version>
```
44 changes: 44 additions & 0 deletions charts/langkit/docs/prepare.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env bash

# Setting common bash options
set -o errexit # Exit on error
set -o nounset # Treat unset variables as an error
set -o pipefail # Consider errors in a pipeline

# Determine the architecture
ARCH=$(uname -m)
case $ARCH in
x86_64)
ARCH=amd64
;;
aarch64 | arm64)
ARCH=arm64
;;
*)
echo "Unsupported architecture: $ARCH"
exit 1
;;
esac
PLATFORM=$(uname -s)_$ARCH

# Install eksctl
curl -sLO "https://github.com/eksctl-io/eksctl/releases/latest/download eksctl_$PLATFORM.tar.gz"
tar -xzf eksctl_$PLATFORM.tar.gz -C /tmp && rm eksctl_$PLATFORM.tar.gz
sudo mv /tmp/eksctl /usr/local/bin

# Validate eksctl installation
if ! command -v eksctl &> /dev/null; then
echo "eksctl could not be installed"
exit 1
fi

# Install helm
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
chmod 700 get_helm.sh
./get_helm.sh

# Validate Helm installation
if ! command -v helm &> /dev/null; then
echo "Helm could not be installed"
exit 1
fi
2 changes: 1 addition & 1 deletion charts/langkit/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ ingress:
image:
repository: registry.gitlab.com/whylabs/langkit-container
pullPolicy: Always
tag: "1.0.13"
tag: "1.0.14"
containerPort: 8000

imagePullSecrets:
Expand Down

0 comments on commit 53081c2

Please sign in to comment.