Skip to content

Commit

Permalink
cleanup repo structure
Browse files Browse the repository at this point in the history
  • Loading branch information
wr0ngway committed Jun 21, 2021
1 parent 7de290f commit 54096a1
Show file tree
Hide file tree
Showing 22 changed files with 342 additions and 294 deletions.
5 changes: 5 additions & 0 deletions .app.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
org: cloudtruth
name: kubetruth
version: 0.5.0


7 changes: 7 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,10 @@ pkg
tmp
packaged-char
old-index.yaml
.bundle
.idea
.codecov.yml
coverage
.dockerignore
.rspec_status
local
46 changes: 17 additions & 29 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,19 @@ jobs:
steps:
- uses: actions/checkout@v2

- uses: actions/cache@v1
with:
path: vendor/bundle
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: |
${{ runner.os }}-gems-
- uses: satackey/[email protected]
continue-on-error: true

- name: Install Ruby version specified in `.ruby-version`
uses: eregon/use-ruby-action@master # this will use by default the .ruby-version file
- name: Set environment from cloudtruth
uses: cloudtruth/configure-action@v1
with:
token: "${{ secrets.CLOUDTRUTH_API_KEY }}"
project: "deploy"
environment: "production"

- run: ruby -v
- run: gem install --no-document bundler
- run: bundle config path vendor/bundle
- run: bundle install --jobs 4 --retry 3
- run: bundle exec rspec
- name: Run the tests
run: |
rake test
deploy:
if: startsWith(github.ref, 'refs/tags/v')
Expand All @@ -37,6 +35,9 @@ jobs:
steps:
- uses: actions/checkout@v2

- uses: satackey/[email protected]
continue-on-error: true

- name: Set environment from cloudtruth
uses: cloudtruth/configure-action@v1
with:
Expand All @@ -54,31 +55,18 @@ jobs:
- name: Build the Docker image
run: |
docker build --target release -t kubetruth .
rake build_release
- name: Push the Docker image
run: |
tag=${GITHUB_REF##*/v}
echo "Pushing version '$tag' to docker hub"
echo "$DOCKERHUB_PASSWORD" | docker login -u "$DOCKERHUB_USERNAME" --password-stdin
docker tag kubetruth cloudtruth/kubetruth:latest
docker push cloudtruth/kubetruth:latest
docker tag kubetruth cloudtruth/kubetruth:${tag}
docker push cloudtruth/kubetruth:${tag}
TAGS="$tag latest" bundle exec rake docker_push
- name: Package helm chart
run: |
export HELM_REPO_URL="${PACKAGES_URL}/${PACKAGES_HELM_PATH}"
mkdir -p tmp/packaged-chart/
(cd tmp/packaged-chart && helm package ../../helm/kubetruth)
./bin/generate-helmv2.sh
(cd tmp/packaged-chart && helm package ../../tmp/helmv2/kubetruth)
maybe_merge=""
if curl -sfL ${HELM_REPO_URL}/index.yaml -o tmp/old-index.yaml; then
maybe_merge="--merge tmp/old-index.yaml"
fi
helm repo index ${maybe_merge} --url ${HELM_REPO_URL} tmp/packaged-chart/
bundle exec rake helm_package
- name: Deploy helm chart to S3
run: |
Expand Down
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
0.5.0 (06/18/2021)
------------------

* remove conditional update as server-side apply takes care of it [7de290f](../../commit/7de290f)
* add a signal handler to wake up from polling sleep [c9c3873](../../commit/c9c3873)
* fix creating namespace [9db00b4](../../commit/9db00b4)
* add context to projectmappings to allow for small modifications (e.g. name, namespace) without having to replace the entire template Made resource_templates into a map, and made override merging of it (and context) be additive in nature so one can add a new mapping with a template without having to replace the existing ones [5d5646b](../../commit/5d5646b)
* add a key_safe filter to ensure ConfigMap/Secret keys are converted to something safe to use [6ef09e1](../../commit/6ef09e1)
* update readme [3249752](../../commit/3249752)
* update readme [bea9ff1](../../commit/bea9ff1)
* Use a list of resource_templates instead of specifically named ones for configmaps and secrets [63d961f](../../commit/63d961f)
* update for new version [353d422](../../commit/353d422)
* Major refactoring to allow using a template for the entire kuberenetes resources (ConfigMaps/Secrets/others) created for each project. [f76e9d2](../../commit/f76e9d2)

0.4.1 (05/19/2021)
------------------

Expand Down
28 changes: 17 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,40 +13,46 @@ ENV APP_DIR="/srv/app" \
# values.
ENV BUNDLE_BIN="${BUNDLE_PATH}/bin" \
GEM_HOME="${BUNDLE_PATH}"
ENV PATH="${APP_DIR}:${BUNDLE_BIN}:${PATH}"
ENV PATH="${APP_DIR}:${APP_DIR}/bin:${BUNDLE_BIN}:${PATH}"

RUN mkdir -p $APP_DIR $BUNDLE_PATH
WORKDIR $APP_DIR

FROM base as build

COPY Gemfile* *.gemspec $APP_DIR/
COPY lib/kubetruth/version.rb $APP_DIR/lib/kubetruth/

RUN apk add --no-cache \
--virtual app \
$APP_PACKAGES && \
apk add --no-cache \
--virtual build_deps \
$BUILD_PACKAGES && \
bundle install && \
apk del build_deps
$BUILD_PACKAGES

COPY Gemfile* $APP_DIR/
RUN bundle config --global without 'development test' && \
bundle install --jobs=4

RUN apk add --no-cache -X http://dl-cdn.alpinelinux.org/alpine/edge/testing kubectl

COPY . $APP_DIR/
RUN bundle config set deployment 'true' && \
bundle config set without 'development test' && \


FROM build as development

RUN bundle config --delete without && \
bundle install --jobs=4

# Specify the script to use when running the container
ENTRYPOINT ["entrypoint.sh"]
# Start the main app process by sending the "app" parameter to the entrypoint
CMD ["app"]


FROM base AS release

RUN apk add --no-cache \
--virtual app \
$RELEASE_PACKAGES

RUN apk add --no-cache -X http://dl-cdn.alpinelinux.org/alpine/edge/testing kubectl

COPY --from=build $BUNDLE_PATH $BUNDLE_PATH
COPY --from=build $APP_DIR $APP_DIR

Expand Down
33 changes: 23 additions & 10 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
source "https://rubygems.org"

# Specify your gem's dependencies in kubetruth.gemspec
gemspec
# development dependencies
group :development do
gem "rake", "~> 12.0"
gem "pry"
gem "pry-byebug"
end

gem "rake", "~> 12.0"
gem "rspec", "~> 3.0"
gem "vcr"
gem "webmock"
gem 'codecov', require: false, group: 'test'
gem "simplecov"
gem "pry"
gem "pry-byebug"
# test dependencies
group :development, :test do
gem "rspec", "~> 3.0"
gem "vcr"
gem "webmock"
gem 'codecov', require: false, group: 'test'
gem "simplecov"
end

# application runtime dependencies
gem 'gem_logger'
gem 'logging'
gem 'activesupport'
gem 'clamp'
gem 'graphql-client'
gem 'kubeclient'
gem 'liquid'
20 changes: 7 additions & 13 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
PATH
remote: .
specs:
kubetruth (0.5.0)
activesupport
clamp
gem_logger
graphql-client
kubeclient
liquid
logging

GEM
remote: https://rubygems.org/
specs:
Expand Down Expand Up @@ -126,8 +114,14 @@ PLATFORMS
ruby

DEPENDENCIES
activesupport
clamp
codecov
kubetruth!
gem_logger
graphql-client
kubeclient
liquid
logging
pry
pry-byebug
rake (~> 12.0)
Expand Down
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@ CloudTruth projects whose names match its `project_selector` pattern.

Note that Kubetruth watches for changes to ProjectMappings, so touching any of
them wakes it up from a polling sleep. This makes it quick and easy to test out
configuration changes without having a short polling interval.
configuration changes without having a short polling interval. You can also
force a wakeup by execing the wakeup script in the running container:
`kubectl exec deployment/kubetruth -- wakeup`

To customize how the kubernetes resources are generated, edit the
`resource_templates` property in the ProjectMappings. These templates are
Expand Down Expand Up @@ -271,15 +273,17 @@ Namespace: default
## Development
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bundle exec rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
After checking out the repo, run `bundle` to install dependencies. Then, run
`bundle exec rspec` to run the tests. You can also run `bundle exec rake console` for an
interactive prompt that will allow you to experiment.
To install and run via helm in a local cluster:
```
# If using minikube, ensure that docker builds the image into the minikube container
# with the command:
# eval $(minikube docker-env)
#
docker build -t kubetruth . && helm install \
docker build --release development -t kubetruth . && helm install \
--set image.repository=kubetruth --set image.pullPolicy=Never --set image.tag=latest \
--set appSettings.debug=true --set appSettings.apiKey=$CLOUDTRUTH_API_KEY --set appSettings.environment=development \
kubetruth ./helm/kubetruth/
Expand Down
Loading

0 comments on commit 54096a1

Please sign in to comment.