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

Bump default image to 1.0.14; Add docs for deploying to fargate #22

Open
wants to merge 8 commits into
base: mainline
Choose a base branch
from
Open
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
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,26 @@
# Downloads a .tgz file to the working directory or --destination path
helm pull \
oci://ghcr.io/whylabs/langkit \
--version "0.10.0"
--version "0.17.0"

helm diff upgrade \
--allow-unreleased \
--namespace langkit \
`# Specify the .tgz file as the chart` \
langkit langkit-0.10.0.tgz
langkit langkit-0.17.0.tgz

helm upgrade --install \
--create-namespace \
--namespace langkit \
langkit langkit-0.10.0.tgz
langkit langkit-0.17.0.tgz
```

#### Extended Example
```shell
# Configure local variables for clarity and simplicity
helm_repo="ghcr.io/whylabs"
chart_name="langkit"
chart_version="0.10.0"
chart_version="0.17.0"
chart="${chart_name}-${chart_version}.tgz"

# Release and namespace values mirror other variables for simplicity.
Expand Down
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"
13 changes: 9 additions & 4 deletions charts/langkit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@

> :warning: Review the [documentation on using WhyLab's Helm charts](../../README.md#how-to-use-whylabs-helm-repository)

## Quickstart

View our [quickstart guide](docs/quickstart/README.md) that sets up a Kubernetes
cluster and deploys Langkit via this chart.

## Prerequisites

NOTE: Change the `--namespace` value if you will be deploying into a namespace other
Expand Down Expand Up @@ -69,22 +74,22 @@ View the difference between the current state and desired state.
# helm plugin install https://github.com/databus23/helm-diff
helm diff upgrade \
--allow-unreleased \
langkit langkit-0.12.0.tgz
langkit langkit-0.17.0.tgz
```

### Install/Update
```shell
helm upgrade --install \
--create-namespace \
--namespace langkit \
langkit langkit-0.12.0.tgz
langkit langkit-0.17.0.tgz
```

### Uninstall
```shell
helm uninstall \
--namespace langkit \
langkit langkit-0.12.0.tgz
langkit langkit-0.17.0.tgz
```

## Development
Expand All @@ -109,7 +114,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
3 changes: 3 additions & 0 deletions charts/langkit/docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Langkit Helm Chart Documentation

[Quickstart Guide](./quickstart/)
146 changes: 146 additions & 0 deletions charts/langkit/docs/quickstart/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
# Quickstart

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

> :warning: This is not intended to be used in a production environment.

## Prerequisites

- An AWS account with appropriate permissions for creating resources.
- Git installed on your local machine.
- WhyLabs and Langkit credentials.

## Clone This Repository

Clone this repository. The following tutorial will be working with the shell
script files within the directory of this `README`.

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

## Environment Setup

- [Recommended] [AWS CloudShell](https://aws.amazon.com/cloudshell/)
- Local terminal

If you're a seasoned pro with AWS and the AWS CLI you can skip ahead to
[using the local terminal](#using-local-terminal).

If you don't already have AWS credentials configured locally, the fastest way to
deploy the Langkit demo cluster is using
[AWS CloudShell](https://aws.amazon.com/cloudshell/), which is a browser-based
shell that already has your credentials configured.

### Using Remote Terminal via [AWS CloudShell](https://aws.amazon.com/cloudshell/)

1. **Login to your AWS Account**

Be sure to login with a role that has sufficient permissions to create
Networking, EC2, EKS, and IAM resources.

1. **Verify that you're in the desired region**

The region can be selected at the top right corner of the AWS console
adjacent to your username/email address.

1. **Search for and select/open the `CloudShell` service**

1. **[Upload the provisioning scripts to the `CloudShell` environment](https://docs.aws.amazon.com/cloudshell/latest/userguide/getting-started.html#folder-upload)**

1. Click the `Actions` drop down menu and choose `Upload File`
1. Select and upload the `prepare.sh`, `deploy-kubernetes.sh`, and
`deploy-langkit.sh` files (one at a time).

### Using Local Terminal

Ensure the AWS enviornment is configured correctly. See the official
[getting started with the AWS CLI documentation](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html)

### Setting Variables

Set the following variables in your shell environment (local or CloudShell).
Variables with default values may be overridden as desired. Variables without
values **must** be configured.

```shell
# AWS and EKS configuration
cluster_name="whylabs"
aws_region="us-west-2"
namespace="default"

# Langkit configuration
chart_version="0.17.0"
whylabs_api_key=""
langkit_password=""
registry_username=""
registry_token=""
```

## Execute Provisioning Scripts

1. **Ensure scripts have execution permissions set**

```shell
chmod 755 prepare.sh deploy-kubernetes.sh 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 Cluster**

This script creates an EKS cluster. By default, it creates a cluster named
`whylabs` in the `us-west-2` region. Change the values to suit your needs.

> :warning: This process takes ~20 minutes

```shell
./deploy-kubernetes.sh \
--cluster-name "${cluster_name}" \
--aws-region "${aws_region}"
```

1. **Deploy Langkit**

```shell
./deploy-langkit.sh \
--chart-version "${chart_version}" \
--whylabs-api_key "${whylabs_api_key}" \
--langkit-password "${langkit_password}" \
--registry-username "${registry_username}" \
--registry-token "${registry_token}"
```

1. **Retrieve Langkit URL**

> :warning: A Network Load Balancer is created by the Langkit service. You
> can reach the service at the DNS address of the load balancer. It may take
> a few moments for the load balancer to be provisioned. The following
> command will return the hostname once it's available.

```shell
hostname=$(kubectl get service langkit \
--namespace "${namespace}" \
-o json | \
jq -r '.status.loadBalancer.ingress[0].hostname')

printf "\nLangkit Hostname: http://${hostname}\n\n"
```

1. **Verify Deployment**

You can confirm that the deployment was successful by executing the
following command. You should see `HTTP/1.1 200 OK` within the response.

```shell
curl -v "http://${hostname}/health"
```
102 changes: 102 additions & 0 deletions charts/langkit/docs/quickstart/deploy-kubernetes.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
#!/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

export AWS_REGION="${aws_region}"

# 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

addons:
- name: vpc-cni
version: latest
attachPolicyARNs:
- arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy
- name: coredns
version: latest
- name: kube-proxy
version: latest

managedNodeGroups:
- name: default
amiFamily: Bottlerocket
spot: true
instanceTypes: ["c7i.2xlarge", "c6i.2xlarge", "c5.2xlarge"]
desiredCapacity: 1
minSize: 1
maxSize: 4
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

# Configure and install the AWS Load Balancer Controller
curl -O https://raw.githubusercontent.com/kubernetes-sigs/aws-load-balancer-controller/v2.7.1/docs/install/iam_policy.json

policyName="AWSLoadBalancerControllerIAMPolicy"
existingPolicyArn=$(aws iam list-policies --query 'Policies[?PolicyName==`'"${policyName}"'`].Arn' --output text)

if [ -z "$existingPolicyArn" ]; then
echo "Policy does not exist. Creating new IAM policy: $policyName"
albPolicyArn=$(aws iam create-policy \
--policy-name "${policyName}" \
--policy-document file://iam_policy.json | jq -r '.Policy.Arn')
else
echo "Policy already exists. Using existing IAM policy ARN: $existingPolicyArn"
albPolicyArn=$existingPolicyArn
fi

# Create the IAM service account with the policy
eksctl create iamserviceaccount \
--cluster="${cluster_name}" \
--namespace=kube-system \
--name=aws-load-balancer-controller \
--role-name AmazonEKSLoadBalancerControllerRole \
--attach-policy-arn="${albPolicyArn}" \
--approve

helm repo add eks https://aws.github.io/eks-charts
helm repo update eks
helm install aws-load-balancer-controller eks/aws-load-balancer-controller \
--namespace kube-system \
--set clusterName="${cluster_name}" \
--set serviceAccount.create=false \
--set serviceAccount.name=aws-load-balancer-controller
Loading
Loading