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

WIP v0.3.2 #129

Open
wants to merge 7 commits into
base: main
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
41 changes: 41 additions & 0 deletions .github/workflows/golang-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Github Actions - Golang
on:
pull_request:
paths:
- '**.go'
permissions:
contents: read
pull-requests: read

defaults:
run:
working-directory: ./shifter

jobs:
golang-ci-workflow:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v3
with:
go-version: '1.19'
- uses: actions/checkout@v3
- name: Run Golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.50.0
args: --issues-exit-code=0 -vc ./.golangci.yaml ./...
working-directory: /home/runner/work/shifter/shifter/shifter
- name: Run Gosec Security Scanner
uses: securego/gosec@master
with:
args: -no-fail -fmt=sarif -out results.sarif -verbose=text ./...
- uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: results.sarif
- name: Run Build
run: make build


# ## we can update once we have unit testcases inplace
# - name: Test
# run: go test
35 changes: 35 additions & 0 deletions .github/workflows/npm-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Github Actions - NPM

on:
workflow_dispatch:
pull_request:
paths:
- '**.js'
- '**.vue'

defaults:
run:
working-directory: ./shifter-ui

jobs:
npm-ci-workflow:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v3
- name: Run ESLint
uses: reviewdog/action-eslint@v1
with:
reporter: github-check
eslint_flags: '. --ext .vue,.js,.jsx,.cjs,.mjs --ignore-path .gitignore'
workdir: './shifter-ui/'
- name: Install
run: npm install
- name: Compile
run: npm run build




3 changes: 0 additions & 3 deletions go.mod

This file was deleted.

19 changes: 19 additions & 0 deletions infra/gke/development.values
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
billing_account_id="xxxxxxx"
parent="organizations/111111111"
project_id="okd-development-123"
project_create="true"

region="us-central1"
vpc_network_name="test"
vpc_subnetwork_name = "test-sn"
vpc_subnetwork_cidr="10.0.0.0/24"
vpc_create="true"

gke_cluster_name="pipeline"
gke_location="us-central1-b"
gke_pods_secondary_cidr="172.16.0.0/20"
gke_services_secondary_cidr="192.168.0.0/24"

gke_nodepool_name="nodepool"
gke_nodepool_count=2

97 changes: 97 additions & 0 deletions infra/gke/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
#! /bin/bash

######################## Optional Vairables(modification not required) ############################
CWD_PATH="$(pwd)"
VALUES_FILE_NAME="development.values"
VALUES_FILE_PATH="$CWD_PATH/$VALUES_FILE_NAME"
#####################################################################
function usage()
{
echo "\n"
echo "The script is used to perform multiple operations on cluster that includes setup and destroy with the help of values file."
echo "It takes option arguments and process them in given order! "
echo ""
echo "USAGE: "
echo "./run.sh"
echo "\t-h --help"
echo "\t--values=development.values (default)"
echo "\t--setup"
echo "\t--destroy"
echo ""
echo "Example:"
echo "sh run.sh --values test.values --setup --destroy"
}

function loadvars()
{
echo "Loading values file: ${VALUES_FILE_PATH}"
set -o allexport
source "$VALUES_FILE_PATH"
set +o allexport
}

function destroy()
{
echo "############################################################"
echo "Initiating the destroy process...."
echo "############################################################"

terraform -chdir=terraform destroy -var-file "$VALUES_FILE_PATH" -auto-approve
}

function setup()
{
echo "############################################################"
echo "Initiating the setup process...."
echo "############################################################"

# Creates pre-reqs for the cluster
terraform -chdir=terraform init
terraform -chdir=terraform plan -var-file "$VALUES_FILE_PATH"
terraform -chdir=terraform apply -var-file "$VALUES_FILE_PATH" -auto-approve

echo "############################################################"
echo "Waiting for 60 seconds for resources to be ready..."
echo "############################################################"
sleep 60

## export kubeconfig on local
gcloud container clusters get-credentials ${gke_cluster_name} --zone ${gke_location}
}



## we want at least one parameter
if [ $# -eq 0 ]; then
usage >&2
exit 1
fi

## handle shell options here
while [ "$1" != "" ]; do
PARAM=`echo $1 | awk -F= '{print $1}'`
VALUE=`echo $1 | awk -F= '{print $2}'`
case $PARAM in
-h | --help)
usage
exit
;;
--values)
VALUES_FILE_NAME=$VALUE
VALUES_FILE_PATH="$CWD_PATH/$VALUES_FILE_NAME"
loadvars
;;
--setup)
setup
;;
--destroy)
destroy
;;
*)
echo "ERROR: unknown parameter \"$PARAM\""
usage
exit 1
;;
esac
shift
done
94 changes: 94 additions & 0 deletions infra/gke/terraform/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@



module "project" {
source = "github.com/GoogleCloudPlatform/cloud-foundation-fabric//modules/project"
billing_account = var.billing_account_id
name = var.project_id
parent = var.parent
prefix = null
project_create = var.project_create
services = [
"compute.googleapis.com",
"cloudapis.googleapis.com",
"cloudresourcemanager.googleapis.com",
"container.googleapis.com",
"iamcredentials.googleapis.com",
"iam.googleapis.com",
"servicemanagement.googleapis.com",
"serviceusage.googleapis.com",
"storage-api.googleapis.com",
"storage-component.googleapis.com",
]
policy_boolean = {
"constraints/iam.disableServiceAccountKeyCreation" = false
"constraints/compute.skipDefaultNetworkCreation" = true
}
policy_list = {
"constraints/compute.restrictLoadBalancerCreationForTypes" = {
inherit_from_parent = null
suggested_value = null
status = true
values = []
},
"constraints/compute.vmExternalIpAccess" = {
inherit_from_parent = null
suggested_value = null
status = true
values = []
},
"constraints/compute.restrictCloudNATUsage" = {
inherit_from_parent = null
suggested_value = null
status = true
values = ["under:projects/${var.project_id}"]
},
}
service_config = {
disable_on_destroy = false
disable_dependent_services = false
}
}

module "vpc" {
source = "github.com/GoogleCloudPlatform/cloud-foundation-fabric/modules/net-vpc"
project_id = module.project.project_id
name = var.vpc_network_name
vpc_create = var.vpc_create
subnets = [
{
ip_cidr_range = var.vpc_subnetwork_cidr
name = var.vpc_subnetwork_name
region = var.region
secondary_ip_range = {
pods = var.gke_pods_secondary_cidr
services = var.gke_services_secondary_cidr
}
}
]
}

module "gke" {
source = "github.com/GoogleCloudPlatform/cloud-foundation-fabric/modules/gke-cluster"
project_id = module.project.project_id
name = var.gke_cluster_name
location = var.gke_location
network = module.vpc.self_link
subnetwork = module.vpc.subnet_self_links["${var.region}/${var.vpc_subnetwork_name}"]
secondary_range_pods = "pods"
secondary_range_services = "services"
default_max_pods_per_node = 32
labels = {
environment = "development"
}
}

module "gke-nodepool" {
source = "github.com/GoogleCloudPlatform/cloud-foundation-fabric/modules/gke-nodepool"
project_id = module.project.project_id
cluster_name = module.gke.name
location = module.gke.location
name = var.gke_nodepool_name
node_count = var.gke_nodepool_count
node_service_account_create = true
}
Loading