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

Experiment with k8s structure pattern #1064

Draft
wants to merge 15 commits into
base: k8-poc
Choose a base branch
from
Draft
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
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
source_cluster:
endpoint: "https://capture-proxy:9200"
endpoint: "https://capture-proxy:9201"
allow_insecure: true
basic_auth:
username: "admin"
password: "admin"
target_cluster:
endpoint: "https://opensearchtarget:9200"
endpoint: "https://opensearch-cluster-master:9200"
allow_insecure: true
basic_auth:
username: "admin"
Expand All @@ -19,14 +19,14 @@ backfill:
replay:
docker:
snapshot:
snapshot_name: "snapshot_2023_01_01"
snapshot_name: "rfs-snapshot"
fs:
repo_path: "/snapshot/test-console"
otel_endpoint: "http://otel-collector:4317"
repo_path: "/storage/snapshot"
otel_endpoint: "http://localhost:4317"
metadata_migration:
from_snapshot:
min_replicas: 0
otel_endpoint: "http://otel-collector:4317"
otel_endpoint: "http://localhost:4317"
kafka:
broker_endpoints: "kafka:9092"
broker_endpoints: "kafka-cluster-kafka-bootstrap:9092"
standard: ""
1 change: 1 addition & 0 deletions deployment/k8/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.tgz
130 changes: 130 additions & 0 deletions deployment/k8/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
# Kubernetes Deployment

## Prerequisites

#### Install kubectl
Follow instructions [here](https://kubernetes.io/docs/tasks/tools/) to install the Kubernetes command-line tool. This will be the go-to tool for interacting with the Kubernetes cluster

#### Install helm
Follow instructions [here](https://helm.sh/docs/intro/install/) to install helm. helm will be used for deploying to the Kubernetes cluster

#### Install docker
Follow instructions [here](https://docs.docker.com/engine/install/) to set up Docker. Docker will be used to build Docker images as well as run a local Kubernetes cluster. Later versions are recommended.


## Local Kubernetes Cluster
Creating a local Kubernetes cluster is useful for testing and developing a given deployment. There are a few different tools for running a Kubernetes cluster locally. This documentation focuses on using [Minikube](https://github.com/kubernetes/minikube) to run the local Kubernetes cluster.

### Install Minikube
Follow instructions [here](https://minikube.sigs.k8s.io/docs/start/?arch=%2Fmacos%2Fx86-64%2Fstable%2Fbinary+download) to install Minikube

### Loading Docker images into Minikube
Since Minikube uses a different Docker registry than the normal host machine, the Docker images shown will differ from that on the host machine. The script `buildDockerImagesMini.sh` in this directory will configure the environment to use the Minikube Docker registry and build the Docker images into Minikube

Show Docker images available to Minikube
```shell
minikube image ls
```
Build Docker images into Minikube
```shell
./buildDockerImagesMini.sh
```

### Start/Pause/Delete
A convenience script `minikubeLocal.sh` is located in this directory which wraps the Minikube commands to start/pause/delete Minikube. This is useful for automatically handling items such as mounting the local repo and creating a tunnel to make localhost calls to containers
```shell
./miniKubeLocal.sh --start
./miniKubeLocal.sh --pause
./miniKubeLocal.sh --delete
```


## Deploying

### Migration Assistant environment
Guide for deploying a complete Migration Assistant environment helm chart, with the ability to enabled/disable different Migration services and clusters as needed

The full environment helm charts consists of:
* Source cluster
* Target cluster
* Migration services

**Note**: For first-time deployments and deployments after changes have been made to a dependent helm package, such as the `migration-console` chart, the following command is needed to update dependent charts
```shell
helm dependency update migration-assistant
```

The full environment helm chart can be deployed with the helm command
```shell
helm install ma migration-assistant
```

### Specific services
Guide for deploying an individual Migration service helm chart

A particular service could then be deployed with a command similar to the below.
```shell
helm install migration-console services/migration-console
```

## Uninstalling
To show all helm deployments
```shell
helm list
```

To uninstall a particular helm deployment
```shell
helm uninstall <deployment_name>
```

### AWS Initial Setup
#### Setting up EBS driver to dynamically provision PVs
```shell
# To check if any IAM OIDC provider is configured:
aws iam list-open-id-connect-providers
# If none exist, create one:
eksctl utils associate-iam-oidc-provider --cluster <cluster_name> --approve
# Create IAM role for service account in order to use EBS CSI driver in EKS
# This currently creates a CFN stack and may
eksctl create iamserviceaccount \
--name ebs-csi-controller-sa \
--namespace kube-system \
--cluster <cluster_name> \
--role-name AmazonEKS_EBS_CSI_DriverRole \
--role-only \
--attach-policy-arn arn:aws:iam::aws:policy/service-role/AmazonEBSCSIDriverPolicy \
--approve
# Install add-on to EKS cluster using the created IAM role for the service account
eksctl create addon --cluster <cluster_name> --name aws-ebs-csi-driver --version latest --service-account-role-arn <role_arn> --force
# Create StorageClass to dynamically provision persistent volumes (PV)
kubectl apply -f aws/storage-class-ebs.yml
```
#### Setting up EFS driver to dynamically provision PVs
```shell
export cluster_name=<cluster_name>
export role_name=AmazonEKS_EFS_CSI_DriverRole
eksctl create iamserviceaccount \
--name efs-csi-controller-sa \
--namespace kube-system \
--cluster $cluster_name \
--role-name $role_name \
--role-only \
--attach-policy-arn arn:aws:iam::aws:policy/service-role/AmazonEFSCSIDriverPolicy \
--approve
TRUST_POLICY=$(aws iam get-role --role-name $role_name --query 'Role.AssumeRolePolicyDocument' | \
sed -e 's/efs-csi-controller-sa/efs-csi-*/' -e 's/StringEquals/StringLike/')
aws iam update-assume-role-policy --role-name $role_name --policy-document "$TRUST_POLICY"
eksctl create addon --cluster $cluster_name --name aws-efs-csi-driver --version latest --service-account-role-arn <role_arn> --force
kubectl apply -f aws/storage-class-efs.yml
```

Create an ECR to store images
```shell
./buildDockerImagesMini.sh --create-ecr
```

Build images and push to ECR
```shell
./buildDockerImagesMini.sh --sync-ecr
```
23 changes: 23 additions & 0 deletions deployment/k8/aws/ack-resource-setup/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
9 changes: 9 additions & 0 deletions deployment/k8/aws/ack-resource-setup/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: v2
name: ack-resource-setup
description: A Helm chart for deploying required AWS resources for running the Migration Assistant
version: 0.1.0
appVersion: "3.5.0"
dependencies:
- name: strimzi-kafka-operator
version: 0.43.0
repository: https://strimzi.io/charts/
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#https://github.com/strimzi/strimzi-kafka-operator/blob/release-0.43.x/examples/kafka/kraft/kafka-single-node.yaml
apiVersion: kafka.strimzi.io/v1beta2
kind: KafkaNodePool
metadata:
name: dual-role
labels:
strimzi.io/cluster: kafka-cluster
spec:
replicas: 1
roles:
- controller
- broker
storage:
type: jbod
volumes:
- id: 0
type: persistent-claim
size: 10Gi
deleteClaim: true
kraftMetadata: shared
---

apiVersion: kafka.strimzi.io/v1beta2
kind: Kafka
metadata:
name: kafka-cluster
annotations:
strimzi.io/node-pools: enabled
strimzi.io/kraft: enabled
spec:
kafka:
version: 3.8.0
metadataVersion: 3.8-IV0
listeners:
- name: plain
port: 9092
type: internal
tls: false
- name: tls
port: 9093
type: internal
tls: true
config:
offsets.topic.replication.factor: 1
transaction.state.log.replication.factor: 1
transaction.state.log.min.isr: 1
default.replication.factor: 1
min.insync.replicas: 1
entityOperator:
topicOperator: {}
userOperator: {}
38 changes: 38 additions & 0 deletions deployment/k8/aws/ack-resource-setup/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Configuration for Strimzi Kafka Operator
#strimzi-kafka-operator:
# You can add operator-specific configurations here if needed
# For example, enabling metrics, RBAC settings, etc.

## Configuration for the Kafka Cluster
#kafka:
# name: kafka-cluster
# version: "3.6.0" # Kafka version supporting KRaft
# replicas: 1
# config:
# processRoles: "broker,controller"
# nodeId: 1
# controllerQuorumVoters: "1@kafka-cluster-0.kafka-cluster-bootstrap:9093"
# interBrokerProtocolVersion: "3.5"
# logMessageFormatVersion: "3.5"
# autoCreateTopicsEnable: "true"
# storage:
# type: "ephemeral" # Use "persistent-claim" for persistent storage
# size: "20Gi"
# class: "managed-nfs-storage" # Set to empty string "" if not using a specific storage class
# deleteClaim: false
#
## Configuration for the Controller
#controller:
# replicas: 1
# resources:
# limits:
# memory: "2Gi"
# cpu: "1000m"
# requests:
# memory: "1Gi"
# cpu: "500m"
# storage:
# type: "ephemeral" # Use "persistent-claim" for persistent storage
# size: "10Gi"
# class: "managed-nfs-storage" # Set to empty string "" if not using a specific storage class
# deleteClaim: false
8 changes: 8 additions & 0 deletions deployment/k8/aws/storage-class-ebs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: ebs-sc
provisioner: ebs.csi.aws.com
volumeBindingMode: WaitForFirstConsumer
parameters:
encrypted: "true"
16 changes: 16 additions & 0 deletions deployment/k8/aws/storage-class-efs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: efs-sc
provisioner: efs.csi.aws.com
parameters:
provisioningMode: efs-ap
fileSystemId: "fs-0bc6e04752a510618"
directoryPerms: "700"
#gidRangeStart: "1000"
#gidRangeEnd: "2000"
#basePath: "/dynamic_provisioning"
#mountOptions:
# - tls
#reclaimPolicy: Retain
volumeBindingMode: Immediate
Loading
Loading