From 1399f382b189608d98cfb2b4a987640d264ae2d3 Mon Sep 17 00:00:00 2001 From: James Pace Date: Fri, 26 Aug 2022 21:46:59 -0400 Subject: [PATCH] Initial clone with pipeline. --- .gitignore | 1 + images/Dockerfile_gitssh | 6 ++++ namespaces/j7s-dev-namspace.json | 10 ++++++ notes.md | 48 +++++++++++++++++++++++++++++ pipelines/git-pipeline.yaml | 53 ++++++++++++++++++++++++++++++++ runs/git-run.yaml | 22 +++++++++++++ 6 files changed, 140 insertions(+) create mode 100644 .gitignore create mode 100644 images/Dockerfile_gitssh create mode 100644 namespaces/j7s-dev-namspace.json create mode 100644 notes.md create mode 100644 pipelines/git-pipeline.yaml create mode 100644 runs/git-run.yaml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4bd922a --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +secrets/ diff --git a/images/Dockerfile_gitssh b/images/Dockerfile_gitssh new file mode 100644 index 0000000..95f6341 --- /dev/null +++ b/images/Dockerfile_gitssh @@ -0,0 +1,6 @@ +FROM docker.io/debian:bullseye-slim + +RUN apt update -y && \ + apt install -y \ + git \ + openssh-client \ No newline at end of file diff --git a/namespaces/j7s-dev-namspace.json b/namespaces/j7s-dev-namspace.json new file mode 100644 index 0000000..c6bb2fe --- /dev/null +++ b/namespaces/j7s-dev-namspace.json @@ -0,0 +1,10 @@ +{ + "apiVersion": "v1", + "kind": "Namespace", + "metadata": { + "name": "j7s-dev", + "labels": { + "name": "j7s-dev" + } + } +} diff --git a/notes.md b/notes.md new file mode 100644 index 0000000..2c21c7a --- /dev/null +++ b/notes.md @@ -0,0 +1,48 @@ +# Notes + +Install: + +1. Set up wireguard. +2. Download k3s install script from website. +3. For master: + `INSTALL_K3S_EXEC="server --node-ip '10.100.100.5' --advertise-address '10.100.100.5' --flannel-iface 'wg0'" ./k3s.sh` +4. For node: + `INSTALL_K3S_EXEC="agent --server 'https://10.100.100.5:6443' --token 'K3S_TOKEN' --node-ip '10.100.100.?' --advertise-address '10.100.100.?' --flannel-iface 'wg0'" ./k3s.sh` +5. Install kubectl on laptop. +6. Copy `/etc/rancher/k3s/k3s.yaml` to laptop and change localhost IP to wireguard IP. +7. `kubectl cluster-info` +8. Install tkn CLI. + `https://tekton.dev/docs/cli/` + I installed manually. + +Set up Tekton: +``` +kubectl apply --filename https://storage.googleapis.com/tekton-releases/pipeline/latest/release.yaml +``` +Set up Tekton Dashboard: +``` +kubectl apply --filename https://storage.googleapis.com/tekton-releases/dashboard/latest/tekton-dashboard-release.yaml +``` +Port forward locally: +``` +kubectl port-forward -n tekton-pipelines service/tekton-dashboard 9097:9097 +``` + +Set up a namespace: +``` +kubectl create -f j7s-dev-namspace.json +``` +``` +kubectl config set-context j7s-dev --namespace=j7s-dev \ + --cluster=j7s-dev \ + --user=default +``` + +Stuff I installed from tkn. +``` +tkn hub install task git-clone +tkn hub install task ansible-runner +tkn hub install task git-batch-merge +``` + + diff --git a/pipelines/git-pipeline.yaml b/pipelines/git-pipeline.yaml new file mode 100644 index 0000000..8093328 --- /dev/null +++ b/pipelines/git-pipeline.yaml @@ -0,0 +1,53 @@ +apiVersion: tekton.dev/v1beta1 +kind: Pipeline +metadata: + name: cat-git-repo +spec: + description: A test pipeline. + params: + - name: repo-url + type: string + description: The git repository URL to clone from. + workspaces: + - name: shared-data + description: Shared data. + - name: git-credentials + description: My ssh credentials + tasks: + - name: fetch-repo + workspaces: + - name: output + workspace: shared-data + - name: ssh-directory + workspace: git-credentials + params: + - name: url + value: $(params.repo-url) + taskSpec: + workspaces: + - name: output + - name: ssh-directory + params: + - name: url + steps: + - image: 192.168.1.128:8443/gitssh:latest + script: | + set -x + cp -r $(workspaces.ssh-directory.path) ~/.ssh + chmod 700 ~/.ssh + chmod -R 400 ~/.ssh/* + git clone $(params.url) $(workspaces.output.path) + + - name: cat-readme + runAfter: ["fetch-repo"] + workspaces: + - name: source + workspace: shared-data + taskSpec: + workspaces: + - name: source + steps: + - image: docker.io/debian:latest + script: | + set -x + cat $(workspaces.source.path)/README diff --git a/runs/git-run.yaml b/runs/git-run.yaml new file mode 100644 index 0000000..5a21cc1 --- /dev/null +++ b/runs/git-run.yaml @@ -0,0 +1,22 @@ +apiVersion: tekton.dev/v1beta1 +kind: PipelineRun +metadata: + name: with-custom-container-2 +spec: + pipelineRef: + name: cat-git-repo + workspaces: + - name: shared-data + volumeClaimTemplate: + spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 1Gi + - name: git-credentials + secret: + secretName: git-credentials + params: + - name: repo-url + value: ssh://git@git.jpace121.net:2222/jimmy/tekton-test.git