Skip to content

Commit

Permalink
feat: bootstrap the repository content (#1)
Browse files Browse the repository at this point in the history
Signed-off-by: Mehdi Bechiri <[email protected]>
  • Loading branch information
cebidhem authored May 23, 2023
1 parent e172db4 commit 7b379e2
Show file tree
Hide file tree
Showing 6 changed files with 116 additions and 0 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Docker

on:
push:
branches:
- main
paths:
- 'Dockerfile'
- 'entrypoint.sh'
- '.github/workflows/docker.yaml'
tags:
- "v*"
pull_request:
branches:
- main
paths:
- 'Dockerfile'
- 'entrypoint.sh'
- '.github/workflows/docker.yaml'

permissions:
contents: read
packages: write

jobs:
push:
runs-on: ubuntu-latest
steps:
- name: 'git:checkout'
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: "docker:meta"
id: meta
uses: docker/metadata-action@v4
with:
images: ghcr.io/${{ github.repository }}
flavor: latest=true
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
- name: "docker:login:ghcr.io"
if: github.ref_type == 'tag'
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GHCR_TOKEN }}
- name: "docker:buildx"
uses: docker/setup-buildx-action@v2
- name: "docker:build-push"
uses: docker/build-push-action@v3
with:
context: .
file: Dockerfile
push: ${{ github.ref_type == 'tag' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea
7 changes: 7 additions & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# This is a comment.
# Each line is a file pattern followed by one or more owners.

# These owners will be the default owners for everything in the repo.
# Unless a later match takes precedence, @cebidhem
# will be requested for review when someone opens a pull request.
* @cebidhem
21 changes: 21 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM alpine:3.18 as base
RUN apk add --no-cache curl openssl
RUN addgroup -g 1001 app && \
adduser -D -G app -u 1001 app

FROM base as builder
ENV KUBECTL_VERSION=1.26.4
ARG TARGETPLATFORM
RUN curl -LO https://dl.k8s.io/release/v${KUBECTL_VERSION}/bin/${TARGETPLATFORM}/kubectl && \
chmod +x ./kubectl && \
curl -LO https://run.linkerd.io/install && \
chmod +x ./install && \
sh install

FROM base as final
COPY --chown=app:app --from=builder kubectl /usr/local/bin/kubectl
COPY --chown=app:app --from=builder /root/.linkerd2/bin/linkerd /usr/local/bin/linkerd
ADD --chown=app:app entrypoint.sh /app/entrypoint.sh
WORKDIR /app
USER app
ENTRYPOINT ["./entrypoint.sh"]
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,23 @@
# linkerd-sp-swagger-sync

Applying Linkerd ServiceProfiles generated from Swagger automatically

### Goal

Linkerd allows to create ServiceProfiles from a Swagger file. This is great when you can generate it locally, or include it somehow in your deployments (Helm, Flux, etc...)

In my case, I want to reconfigure the ServiceProfile of my backends each time I deploy it in Kubernetes, without wondering if my routes have been updated this time or not. Obviously, several version live at the same time in different clusters, I just don't want to track that.

This docker image aims at getting a Swagger documentation online, process it with linkerd commands to generate the ServiceProfile and apply it in cluster.

In my case, I'll run it as a Helm post-upgrade hook.

### Non Goals

This fulfills a very specific use-case and yours may be different. If your contributions are welcomed, please note that this is a side project that I'll maintain on my free time on a best effort basis.

Of course, feel also free to fork the project: it's under the [MIT license](LICENSE).

### How to run it ?

Work In Progress
6 changes: 6 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env sh

SWAGGER_URL=$1
SERVICE=$2

curl "${SWAGGER_URL}" | linkerd profile --open-api - "${SERVICE}" | kubectl apply -f -

0 comments on commit 7b379e2

Please sign in to comment.