<commit_before>#!/bin/bash

# Copyright 2016 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


###############################################################################
#
# dev-build.sh
#
# Convenience script for developing kops AND nodeup.
#
# This script (by design) will handle building a full kops cluster in AWS,
# with a custom version of the Nodeup binary compiled at runtime.
# 
# This script and Makefile uses aws client
# https://aws.amazon.com/cli/
# and make sure you `aws configure` 
#
# Example usage
#
# STATE_STORE="s3://my-dev-s3-state \
# CLUSTER_DOMAIN="mydomain.io" \
# CLUSTER_PREFIX="prefix" \
# NODEUP_BUCKET="s3-devel-bucket-name-store-nodeup" \
# ./dev-build.sh
#
###############################################################################

# This script assumes it's in $KOPS/hack

[ -z "$STATE_STORE" ] && echo "Need to set STATE_STORE" && exit 1;
[ -z "$CLUSTER_DOMAIN" ] && echo "Need to set CLUSTER_DOMAIN" && exit 1;
[ -z "$CLUSTER_PREFIX" ] && echo "Need to set CLUSTER_PREFIX" && exit 1;
[ -z "$NODEUP_BUCKET" ] && echo "Need to set NODEUP_BUCKET" && exit 1;

# TODO make this better
CLUSTER_ENV="dev"
CLUSTER_REGION="us-west-2"
CLUSTER_SUBDOMAIN="aws-${CLUSTER_REGION}"
CLUSTER_NAME="${CLUSTER_PREFIX}.${CLUSTER_ENV}.${CLUSTER_SUBDOMAIN}.${CLUSTER_DOMAIN}"

# CLUSTER CONFIG
NODE_COUNT=${NODE_COUNT:-3}
NODE_ZONES=${NODE_ZONES:-"us-west-2a,us-west-2b,us-west-2c"}
NODE_SIZE=${NODE_SIZE:-m4.xlarge}
MASTER_ZONES=${MASTER_ZONES:-"us-west-2a,us-west-2b,us-west-2c"}
MASTER_SIZE=${MASTER_SIZE:-m4.large}

# NETWORK
TOPOLOGY=${TOPOLOGY:-private}
NETWORKING=${NETWORKING:-cni}

# NODEUP
NODEUP_OS="linux"
NODEUP_ARCH="amd64"

cd ../

GIT_VER=git-$(git describe --always)
# TODO check that GIT_VER worked
NODEUP_URL="https://s3-us-west-1.amazonaws.com/${NODEUP_BUCKET}/kops/${GIT_VER}/${NODEUP_OS}/${NODEUP_ARCH}/nodeup"

VERBOSITY=${VERBOSITY:-2}

make upload STATE_STORE=s3://${NODEUP_BUCKET}

echo ==========
echo "Deleting cluster ${CLUSTER_NAME}"

kops delete cluster \
  --name $CLUSTER_NAME \
  --state $STATE_STORE \
  -v $VERBOSITY \
  --yes

echo ==========
echo "Creating cluster ${CLUSTER_NAME}"

NODEUP_URL=${NODEUP_URL} kops create cluster \
  --name $CLUSTER_NAME \
  --state $STATE_STORE \
  --node-count $NODE_COUNT \
  --zones $NODE_ZONES \
  --master-zones $MASTER_ZONES \
  --cloud aws \
  --dns-zone ${CLUSTER_SUBDOMAIN}.${CLUSTER_DOMAIN} \
  --node-size $NODE_SIZE \
  --master-size $MASTER_SIZE \
  --topology $TOPOLOGY \
  --networking $NETWORKING \
  -v $VERBOSITY \
  --yes

echo ==========
echo "Your k8s cluster ${CLUSTER_NAME}, awaits your bidding"<commit_msg>more tweaks<commit_after>#!/bin/bash

# Copyright 2016 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


###############################################################################
#
# dev-build.sh
#
# Convenience script for developing kops AND nodeup.
#
# This script (by design) will handle building a full kops cluster in AWS,
# with a custom version of the Nodeup binary compiled at runtime.
# 
# This script and Makefile uses aws client
# https://aws.amazon.com/cli/
# and make sure you `aws configure` 
#
# Example usage
#
# STATE_STORE="s3://my-dev-s3-state \
# CLUSTER_NAME="fullcluster.name.mydomain.io" \
# NODEUP_BUCKET="s3-devel-bucket-name-store-nodeup" \
# ./dev-build.sh
#
###############################################################################

set -o errexit
set -o pipefail

KOPS_DIRECTORY="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

[ -z "$STATE_STORE" ] && echo "Need to set STATE_STORE" && exit 1;
[ -z "$CLUSTER_NAME" ] && echo "Need to set CLUSTER_NAME" && exit 1;
[ -z "$NODEUP_BUCKET" ] && echo "Need to set NODEUP_BUCKET" && exit 1;

# CLUSTER CONFIG
NODE_COUNT=${NODE_COUNT:-3}
NODE_ZONES=${NODE_ZONES:-"us-west-2a,us-west-2b,us-west-2c"}
NODE_SIZE=${NODE_SIZE:-m4.xlarge}
MASTER_ZONES=${MASTER_ZONES:-"us-west-2a,us-west-2b,us-west-2c"}
MASTER_SIZE=${MASTER_SIZE:-m4.large}

# NETWORK
TOPOLOGY=${TOPOLOGY:-private}
NETWORKING=${NETWORKING:-cni}

# NODEUP
NODEUP_OS="linux"
NODEUP_ARCH="amd64"

cd $KOPS_DIRECTORY/..

GIT_VER=git-$(git describe --always)
[ -z "$GIT_VER" ] && echo "we do not have GIT_VER something is very wrong" && exit 1;
NODEUP_URL="https://s3-us-west-1.amazonaws.com/${NODEUP_BUCKET}/kops/${GIT_VER}/${NODEUP_OS}/${NODEUP_ARCH}/nodeup"

VERBOSITY=${VERBOSITY:-2}

make upload STATE_STORE=s3://${NODEUP_BUCKET}

echo ==========
echo "Deleting cluster ${CLUSTER_NAME}. Elle est finie."

kops delete cluster \
  --name $CLUSTER_NAME \
  --state $STATE_STORE \
  -v $VERBOSITY \
  --yes

echo ==========
echo "Creating cluster ${CLUSTER_NAME}"

NODEUP_URL=${NODEUP_URL} kops create cluster \
  --name $CLUSTER_NAME \
  --state $STATE_STORE \
  --node-count $NODE_COUNT \
  --zones $NODE_ZONES \
  --master-zones $MASTER_ZONES \
  --cloud aws \
  --node-size $NODE_SIZE \
  --master-size $MASTER_SIZE \
  --topology $TOPOLOGY \
  --networking $NETWORKING \
  -v $VERBOSITY \
  --yes

echo ==========
echo "Your k8s cluster ${CLUSTER_NAME}, awaits your bidding."
{'fraction_non_alphanumeric': 0.19573420836751435, 'fraction_numerical': 0.010500410172272354, 'mean_word_length': 4.457475380483438, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1500109', 'n_tokens_mistral': 2211, 'n_tokens_neox': 2167, 'n_words': 542}