Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
e07fadd
Updates to be usable in MIR clusters
rewagner87 Jan 15, 2021
9b2e6e7
Merge pull request #1 from johndoe0920/users/rowagne/updates_for_MIR
rewagner87 Jan 15, 2021
86f024b
Set up CI with Azure Pipelines
rewagner87 Jan 15, 2021
86ffc08
Updating maxUnavailable
rewagner87 Jan 20, 2021
bb05bde
Some changes for build
rewagner87 Jan 20, 2021
d40b724
Merge branch 'master' into users/rowagne/updates_for_build
rewagner87 Jan 20, 2021
926cef5
Making more changes
rewagner87 Jan 21, 2021
15b13a7
Merge pull request #2 from johndoe0920/users/rowagne/updates_for_build
rewagner87 Jan 21, 2021
889f8f8
Changes to vsts build
rewagner87 Jan 21, 2021
aabfd9e
Update azure-pipelines.yml for Azure Pipelines
rewagner87 Jan 21, 2021
f2dc8d7
Update azure-pipelines.yml for Azure Pipelines
rewagner87 Jan 21, 2021
08a52ff
Moving stuff to make full_drop work
rewagner87 Jan 21, 2021
8585449
Merge branch 'users/rowagne/updates_to_build' of github.com:johndoe09…
rewagner87 Jan 21, 2021
de92b5f
Update azure-pipelines.yml for Azure Pipelines
rewagner87 Jan 21, 2021
04e0ede
updating task.sh
rewagner87 Jan 21, 2021
5749521
Update task.sh again
rewagner87 Jan 21, 2021
bbafa40
removing mkver
rewagner87 Jan 21, 2021
f7d0471
MOre updates
rewagner87 Jan 21, 2021
f7de4a1
Cleaning up some values.
rewagner87 Jan 21, 2021
25d8693
Updating pipeline
rewagner87 Jan 21, 2021
0502114
Updating pipeline
rewagner87 Jan 21, 2021
078dc9b
More changes
rewagner87 Jan 21, 2021
e0ab36d
More radical changes
rewagner87 Jan 21, 2021
7aa3a25
Adding namespace
rewagner87 Jan 21, 2021
59d7f20
Merge pull request #3 from johndoe0920/users/rowagne/updates_to_build
rewagner87 Jan 21, 2021
ef7a158
Update azure-pipelines.yml for Azure Pipelines
rewagner87 Jan 21, 2021
708b7a8
Update azure-pipelines.yml for Azure Pipelines
rewagner87 Jan 21, 2021
c9be638
Updating dotnet from 2.0 to 5.0 to deal with vulnerabilities.
rewagner87 Jan 27, 2021
790fb13
Adding update and upgrade
rewagner87 Jan 28, 2021
91c552e
Adding update and upgrade
rewagner87 Jan 28, 2021
905b126
Merge pull request #4 from johndoe0920/users/rowagne/update_dotnet_5_0
rewagner87 Jan 28, 2021
72e1a5b
Making CI and Master builds
rewagner87 Jan 28, 2021
55b66ba
Merge pull request #5 from johndoe0920/users/rowagne/change_vsts_builds
rewagner87 Jan 28, 2021
07fa11c
Test file
rewagner87 Jan 28, 2021
74db47e
Update .vsts-master.yml for Azure Pipelines
rewagner87 Jan 28, 2021
538b0e0
Test file
rewagner87 Jan 28, 2021
4edb255
Merge pull request #6 from johndoe0920/users/rowagne/test_builds
rewagner87 Jan 28, 2021
5f8b571
Removing test and azure-pipeline files
rewagner87 Jan 28, 2021
d59a2ff
Merge pull request #7 from johndoe0920/users/rowagne/removing_unneede…
rewagner87 Jan 28, 2021
64c165d
Adding node selector for only linux nodes
rewagner87 Feb 12, 2021
9a9045f
Fixing placement of nodeSelector
rewagner87 Feb 12, 2021
faa5095
Merge pull request #8 from johndoe0920/users/rowagne/adding_node_sele…
rewagner87 Feb 12, 2021
fa68207
Updating agent pool for vsts builds
rewagner87 Jul 26, 2021
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
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ install:
- docker build -t docker-gc-helm-chart-validate -f Dockerfile.helmtest .

script:
- docker build -t jackil/docker-gc -f Dockerfile .
- docker build -t src/docker-cache-cleaner -f Dockerfile .

after_success:
- docker build -t jackil/docker-gc -f Dockerfile .
- docker build -t src/docker-cache-cleaner -f Dockerfile .
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceRoot}/DockerGC/bin/Debug/netcoreapp2.0/DockerGC.dll",
"program": "${workspaceRoot}/DockerGC/bin/Debug/netcoreapp5.0/DockerGC.dll",
"args": [],
"cwd": "${workspaceRoot}",
// For more information about the 'console' field, see https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md#console-terminal-window
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,6 @@ For custom configurations, please head to values.yaml.

docker-gc.service is an example of using it with fleet.

## Run and create namespace

helm install --generate-name jackil-docker-gc -n <namespace> --create-namespace
60 changes: 60 additions & 0 deletions deploy/specs/all-base.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
# --- ABSTRACT ALL BASE ---
# -------------------------
envs:
all-base:
abstract: true
spec:
__name__: ~ # spec will inject the env name as env.__name__
#-----apps
apps:
__base__: # the __base__ app gets inherited by all other apps
__name__: ~ # this instructs conf to inject the app name as app.__name__
__anchor__: app
build:
__base__:
publish: false # infra repo opted-out from msftkube builds
docker:
__omit_base__: [ 'publish' ] # do not inherit this setting
builds:
__base__: # this __base__ docker build gets inherited by all docker builds
dir: "{{app.build.dotnet.outdir}}"
checksum: True # with <Deterministic>true</Deterministic>, always checksum the dir
# if a savePath is specified in docker build def then a tarball of the image will be saved into the image. It can be quite big.
# savePath: "{{paths.drop}}/docker/images/{{app.__name__}}.tar.gz"
k8s:
source: "{{paths.k8s.source}}/{{app.__name__}}.yaml"
destinationDirectory: "{{paths.k8s.dest}}"
parameters:
replicaCount: 2
azure:
__base__: # base here is the type of azure resource: sql, acs, etc
__base__: # base is a specific named azure resource: sql-server-01, cluster-01, storage-01
subscription: "{{deploy.azure.subscription}}"
region: "{{deploy.azure.region}}"
group: "{{deploy.azure.group}}"
docker-cache-cleaner:
k8s:
parameters:
namespace: docker-cache-cleaner
fullname: docker-cache-cleaner
chartName: docker-cache-cleaner
imagePullPolicy: IfNotPresent
allowMissingResourceFiles: True
recyclingStrategy: ByDate
dockerEndpoint: unix:///var/run/docker.sock
executionIntervalInMinutes: 360
dockerClientTimeoutInSeconds: 180
imageDeletionOrder: ByImageLastTouchDate
strategy: ByDate
daysBeforeDeletion: 1
containerStateBlacklist: dead,exited
socketPath: /var/run/docker.sock
volumeName: docker-volume
resources:
limits:
cpu: 100m
memory: 128Mi
requests:
cpu: "0"
memory: 128Mi
14 changes: 14 additions & 0 deletions deploy/specs/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apps:
__base__: # this __base__ app gets inherited by all other apps
__name__: ~ # this instructs spec to inject the app name as app.__name__
__anchor__: app
icm:
routingId: Vienna-MIR
docker-cache-cleaner:
deploymentGroups:
- "default"
build:
docker:
builds:
docker-cache-cleaner:
dir: "{{paths.src}}"
11 changes: 11 additions & 0 deletions deploy/specs/path.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
paths:
acs:
source: "{{paths.root}}/deploy/templates/acs"
dest: "{{paths.drop}}/arm"
k8s:
source: "{{paths.root}}/deploy/templates/k8s"
dest: "{{paths.drop}}/k8s"
helm:
source: "{{paths.root}}/deploy/templates/helm"
dest: "{{paths.drop}}/helm"
src: "{{paths.root}}/src"
9 changes: 9 additions & 0 deletions deploy/specs/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
publish:
azure:
keyvault:
name: vienna-test-westus
docker:
registry:
name: viennadroptest
resourceGroup: viennadroptest
subscription: ad203158-bc5d-4e72-b764-2607833a71dc
33 changes: 33 additions & 0 deletions deploy/templates/helm/docker-cache-cleaner-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Default values for docker-gc.
image:
repository: viennadroptest.azurecr.io/docker-cache-cleaner
tag: "{{app.drop.images.docker-cache-cleaner.tag}}"
pullPolicy: IfNotPresent
docker:
socketPath: /var/run/docker.sock
volumeName: docker-volume
fullname: docker-cache-cleaner
fullnameOverride: docker-cache-cleaner
nameOverride: docker-cache-cleaner
statsd:
enabled: false
#host: localhost
#port: 8125
config:
dockerEndpoint: unix:///var/run/docker.sock
executionIntervalInMinutes: 360
dockerClientTimeoutInSeconds: 180
imageDeletionOrder: ByImageLastTouchDate
strategy: ByDate
daysBeforeDeletion: 1
containerStateBlacklist: dead,exited
nodeSelector:
beta.kubernetes.io/os: linux
resources:
limits:
cpu: 100m
memory: 128Mi
requests:
cpu: "0"
memory: 128Mi

61 changes: 61 additions & 0 deletions deploy/templates/k8s/docker-cache-cleaner.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: "{{app.k8s.parameters.fullname}}"
namespace: "{{app.k8s.parameters.namespace}}"
labels:
app: "{{app.k8s.parameters.fullname}}"
chart: "{{app.k8s.parameters.chartName}}"
spec:
selector:
matchLabels:
app: docker-cache-cleaner
template:
metadata:
labels:
app: docker-cache-cleaner
spec:
containers:
- name: "{{app.k8s.parameters.fullname}}"
image: "{{publish.docker.registry.hostname}}/{{app.drop.images.docker-cache-cleaner.name}}:{{app.drop.images.docker-cache-cleaner.tag}}"
imagePullPolicy: "{{app.k8s.parameters.imagePullPolicy}}"
resources:
limits:
cpu: "{{app.resources.limits.cpu}}"
memory: "{{app.resources.limits.memory}}"
requests:
cpu: "{{app.resources.requests.cpu}}"
memory: "{{app.resources.requests.memory}}"
env:
- name: DOCKERGC_RECYCLING_STRATEGY
value: "{{app.k8s.parameters.recyclingStrategy}}"
- name: DOCKERGC_EXECUTION_INTERVAL_IN_MINUTES
value: "{{app.k8s.parameters.executionIntervalInMinutes}}"
- name: DOCKERGC_DOCKER_ENDPOINT
value: "{{app.k8s.parameters.dockerEndpoint}}"
- name: DOCKERGC_CONTAINER_STATE_BLACKLIST
value: "{{app.k8s.parameters.containerStateBlacklist}}"
- name: DOCKERGC_IMAGE_DELETION_ORDER
value: "{{app.k8s.parameters.imageDeletionOrder}}"
- name: DOCKERGC_DOCKER_CLIENT_TIMEOUT_IN_SECONDS
value: "{{app.k8s.parameters.dockerClientTimeoutInSeconds}}"
- name: DOCKERGC_DAYS_BEFORE_DELETION
value: "{{app.k8s.parameters.daysBeforeDeletion}}"
volumeMounts:
- mountPath: "{{app.k8s.parameters.socketPath}}"
name: "{{app.k8s.parameters.volumeName}}"
nodeSelector:
beta.kubernetes.io/os: linux
tolerations:
- effect: NoSchedule
operator: Exists
- effect: NoExecute
operator: Exists
volumes:
- name: "{{app.k8s.parameters.volumeName}}"
hostPath:
path: "{{app.k8s.parameters.socketPath}}"
updateStrategy:
rollingUpdate:
maxUnavailable: 100%
type: RollingUpdate
Empty file added deploy/templates/k8s/readme.md
Empty file.
10 changes: 0 additions & 10 deletions helm-chart/jackil-docker-gc/Chart.yaml

This file was deleted.

59 changes: 59 additions & 0 deletions scripts/task.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# pylint: disable=locally-disabled,line-too-long,missing-docstring
import os
import argparse
import logging
import shutil

import msftkube as mk

mk.steps.acs.TEMPLATE_TRANSFORMERS = [
# _transformer_encrypt_storages,
# mk.steps.acs._transformer_do_not_use_port_22,
# _transformer_add_security_extension,
mk.steps.acs._parameters_change_to_keyvault_reference('servicePrincipalClientId'),
mk.steps.acs._parameters_change_to_keyvault_reference('sshRSAPublicKey'),
mk.steps.acs._parameters_change_to_keyvault_reference('servicePrincipalClientSecret')
]

def main():

commands = mk.commands.DEFAULT_COMMANDS

context = mk.context.create(commands.keys())

# determine paths. Script could be in repository or a build drop
script_dir = os.path.dirname(__file__)
root_dir = os.path.abspath(os.path.join(script_dir, '..'))
if os.path.isdir(os.path.join(root_dir, 'src')):
# we are in repository
drop_dir = os.path.join(root_dir, 'build')
mk.util.ensure_dir(drop_dir)
def copy_scripts_into_drop(spec, context): # pylint: disable=unused-argument
mk.logger.info('task.py - Copying scripts into drop folder')
scripts_dest = os.path.join(drop_dir, 'scripts')
mk.util.copytree_clobber(script_dir, scripts_dest)
mk.util.copytree_clobber(mk.__path__[0], os.path.join(scripts_dest, 'msftkube'))
mk.util.copytree_clobber(os.path.join(root_dir, 'deploy'), os.path.join(drop_dir, 'deploy'))
commands['publish'] += [copy_scripts_into_drop]
else:
# we are in a build drop outside of the repository
drop_dir = root_dir

mk.logger.info('task.py - Drop dir path is %s', drop_dir)

# write log file to drop
mk.logger.addFileHandler(os.path.join(drop_dir, 'build.log'))

# Seed spec from paths and args
seed_spec = {'paths': {'drop': drop_dir}}

# provide user args & context to steps

# read specs from files into spec
spec = mk.spec.create(root_dir, [seed_spec, os.path.join(root_dir, 'deploy', 'specs')])

# run any steps selected
mk.commands.execute(commands, spec, context)

if __name__ == '__main__':
main()
11 changes: 11 additions & 0 deletions scripts/task.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash
set -ex

PARENT_DIR=$(realpath `dirname $0`/..)

python -m venv /tmp/aml-venv
source /tmp/aml-venv/bin/activate
wget -O - https://aka.ms/msftkube-bootstrapper.sh | bash

cd $PARENT_DIR
msftkube "$@"
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<TargetFramework>netcoreapp5.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion DockerGC/DockerGC.csproj → src/DockerGC/DockerGC.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework>
<TargetFramework>netcoreapp5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Docker.DotNet" Version="3.125.0" />
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 4 additions & 2 deletions Dockerfile → src/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
FROM microsoft/dotnet:2.0-sdk AS build-env
FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build-env
WORKDIR /docker-gc

COPY DockerGC ./

RUN dotnet publish -c Release -o out

# build runtime image
FROM microsoft/dotnet:2.0-runtime
FROM mcr.microsoft.com/dotnet/runtime:5.0
WORKDIR /docker-gc
COPY --from=build-env /docker-gc/out ./

RUN apt update && apt upgrade -y && apt autoclean

ENV DOCKERGC_DOCKER_ENDPOINT unix:///var/run/docker.sock
ENV DOCKERGC_EXECUTION_INTERVAL_IN_MINUTES 720
ENV DOCKERGC_DOCKER_CLIENT_TIMEOUT_IN_SECONDS 180
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile.helmtest → src/Dockerfile.helmtest
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ RUN /bin/helm init --client-only && /bin/helm repo update

WORKDIR ["/bin/helm"]

COPY helm-chart/jackil-docker-gc jackil-docker-gc
COPY src/docker-cache-cleaner docker-cache-cleaner

RUN MSG=$(helm lint jackil-docker-gc | grep "no failures")
RUN MSG=$(helm lint docker-cache-cleaner | grep "no failures")

RUN echo $MSG

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.test → src/Dockerfile.test
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# DockerGC Unit Tests Dockerfile

FROM microsoft/dotnet:2.0-sdk
FROM mcr.microsoft.com/dotnet/sdk:5.0

COPY DockerGC DockerGC
COPY DockerGC.Tests DockerGC.Tests
Expand Down
Empty file added src/README.md
Empty file.
12 changes: 12 additions & 0 deletions src/docker-cache-cleaner/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: docker-cache-cleaner
description: A Docker Image Garbage Collector Helm chart for Kubernetes
home: https://github.com/johndoe0920/docker-gc
version: 1.0.0
appVersion: 1.0.0
sources:
- https://github.com/johndoe0920/docker-gc
maintainers:
- name: Jiaqi Liu
email: jackil@Microsoft.com
- name: Ross Wagner
email: rowagne@microsoft.com
Loading