Skip to content

Commit

Permalink
setup github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
binayakd committed May 3, 2024
1 parent 426884b commit 0919ab7
Show file tree
Hide file tree
Showing 10 changed files with 68 additions and 144 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/build-metastore-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Create and publish metastore Docker image

on:
push:
branches: ['main']

env:
REGISTRY: ghcr.io
IMAGE_NAME: binayakd/metastore
TAG: 4.0.0-hadoop-3.4.0


jobs:
build-and-push-image:
runs-on: ubuntu-latest

permissions:
contents: read
packages: write
# attestations: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push
uses: docker/build-push-action@v5
with:
context: hive-standalone-metastore/image
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.TAG }}
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ ARG RUN_AS_USER=1000
ARG RUN_AS_GROUP=1000

# Versions
ARG HSM_VERSION=4.0.0
ARG METASTORE_VERSION=4.0.0
ARG HADOOP_VERSION=3.4.0
ARG POSTGRES_DRIVER_VERSION=42.7.3

# update and install java and dependencies
RUN microdnf update -y \
&& microdnf --nodocs install java-17-openjdk-headless tar shadow-utils gzip gettext -y \
&& microdnf --nodocs install shadow-utils java-17-openjdk-headless tar gzip gettext -y \
&& microdnf clean all -y

# set up non root user
Expand All @@ -37,9 +37,9 @@ RUN curl https://dlcdn.apache.org/hadoop/common/hadoop-$HADOOP_VERSION/hadoop-$H
&& rm -r ${HADOOP_HOME}/share/doc

# Download the standalone hive metastore
RUN curl https://repo1.maven.org/maven2/org/apache/hive/hive-standalone-metastore-server/${HSM_VERSION}/hive-standalone-metastore-server-${HSM_VERSION}-bin.tar.gz \
RUN curl https://repo1.maven.org/maven2/org/apache/hive/hive-standalone-metastore-server/${METASTORE_VERSION}/hive-standalone-metastore-server-${HSM_VERSION}-bin.tar.gz \
| tar xz -C /opt/ \
&& ln -s /opt/apache-hive-metastore-${HSM_VERSION}-bin ${METASTORE_HOME} \
&& ln -s /opt/apache-hive-metastore-${METASTORE_VERSION}-bin ${METASTORE_HOME} \
# fix for schemaTool script
&& sed -i -e 's/org.apache.hadoop.hive.metastore.tools.MetastoreSchemaTool/org.apache.hadoop.hive.metastore.tools.schematool.MetastoreSchemaTool/g' ${METASTORE_HOME}/bin/ext/schemaTool.sh

Expand All @@ -48,9 +48,6 @@ WORKDIR ${METASTORE_HOME}
RUN curl https://repo1.maven.org/maven2/org/postgresql/postgresql/${POSTGRES_DRIVER_VERSION}/postgresql-${POSTGRES_DRIVER_VERSION}.jar \
-o lib/postgresql-${POSTGRES_DRIVER_VERSION}.jar

COPY --chown=hsm:hsm conf/metastore-log4j2.properties conf/metastore-log4j2.properties
COPY --chown=hsm:hsm conf/core-site.xml.tpl conf/tpl/core-site.xml.tpl
COPY --chown=hsm:hsm conf/metastore-site.xml.tpl conf/tpl/metastore-site.xml.tpl
COPY --chown=hsm:hsm --chmod=775 entrypoint.sh bin/entrypoint.sh

CMD ["bash", "-c", "bin/entrypoint.sh"]
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ initSchema () {
fi
}

log "INFO" "Templating core-site.xml"
envsubst < conf/tpl/core-site.xml.tpl > conf/core-site.xml
# log "INFO" "Templating core-site.xml"
# envsubst < conf/tpl/core-site.xml.tpl > conf/core-site.xml

log "INFO" "Templating metastore-site.xml"
envsubst < conf/tpl/metastore-site.xml.tpl > conf/metastore-site.xml
# log "INFO" "Templating metastore-site.xml"
# envsubst < conf/tpl/metastore-site.xml.tpl > conf/metastore-site.xml


if initSchema
Expand Down
File renamed without changes.
23 changes: 0 additions & 23 deletions images/hive-standalone-metastore/conf/core-site.xml.tpl

This file was deleted.

71 changes: 0 additions & 71 deletions images/hive-standalone-metastore/conf/metastore-log4j2.properties

This file was deleted.

34 changes: 0 additions & 34 deletions images/hive-standalone-metastore/conf/metastore-site.xml.tpl

This file was deleted.

2 changes: 1 addition & 1 deletion terraform/aws-resources/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ module "eks" {
trino = {
min_size = 1
max_size = 3
desired_size = 3
desired_size = 1

instance_types = ["t3.medium"]
capacity_type = "SPOT"
Expand Down
19 changes: 15 additions & 4 deletions terraform/kube-resources/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ locals {
}
}

data "aws_eks_cluster" "default" {
data "aws_eks_cluster" "trino_on_eks" {
name = local.name
}

data "aws_eks_cluster_auth" "default" {
data "aws_eks_cluster_auth" "trino_on_eks" {
name = local.name
}

Expand All @@ -37,14 +37,14 @@ data "aws_secretsmanager_secret_version" "rds_password" {


provider "kubernetes" {
host = data.aws_eks_cluster.default.endpoint
host = data.aws_eks_cluster.trino_on_eks.endpoint
cluster_ca_certificate = base64decode(data.aws_eks_cluster.default.certificate_authority[0].data)
token = data.aws_eks_cluster_auth.default.token
}

provider "helm" {
kubernetes {
host = data.aws_eks_cluster.default.endpoint
host = data.aws_eks_cluster.trino_on_eks.endpoint
cluster_ca_certificate = base64decode(data.aws_eks_cluster.default.certificate_authority[0].data)
token = data.aws_eks_cluster_auth.default.token
}
Expand Down Expand Up @@ -111,6 +111,7 @@ resource "kubernetes_manifest" "deployment_hive_standalone_metastore" {
"app" = "hsm"
}
"name" = "hive-standalone-metastore"
"namespace" = local.kube_namespace
}
"spec" = {
"replicas" = 1
Expand Down Expand Up @@ -168,3 +169,13 @@ resource "kubernetes_manifest" "deployment_hive_standalone_metastore" {
}
}
}


resource "helm_release" "trino" {
name = "trino"
namespace = local.kube_namespace

repository = "https://trinodb.github.io/charts/"
chart = "trino/trino"

}

0 comments on commit 0919ab7

Please sign in to comment.