From 54a8d4140d58c9574b183163e0896dc653e88482 Mon Sep 17 00:00:00 2001 From: DanG100 Date: Mon, 31 Oct 2022 17:29:06 +0000 Subject: [PATCH] better setup --- cloudbuild/Dockerfile | 14 ++++++++++++++ cloudbuild/kne.yaml | 5 +++++ cloudbuild/presubmit.sh | 4 ++-- kne/deploy.sh | 24 ------------------------ kne/setup.sh | 35 ----------------------------------- 5 files changed, 21 insertions(+), 61 deletions(-) create mode 100644 cloudbuild/Dockerfile create mode 100644 cloudbuild/kne.yaml delete mode 100755 kne/deploy.sh delete mode 100755 kne/setup.sh diff --git a/cloudbuild/Dockerfile b/cloudbuild/Dockerfile new file mode 100644 index 00000000..36582356 --- /dev/null +++ b/cloudbuild/Dockerfile @@ -0,0 +1,14 @@ +FROM gcr.io/cloud-builders/docker +RUN echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | tee -a /etc/apt/sources.list.d/google-cloud-sdk.list +RUN curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key --keyring /usr/share/keyrings/cloud.google.gpg add - +RUN apt-get update && apt-get install google-cloud-cli +RUN gcloud source repos clone kne-internal --project=gep-kne +RUN gcloud source repos clone keysight --project=gep-kne +RUN curl -L https://storage.googleapis.com/kubernetes-release/release/v1.26.2/bin/linux/amd64/kubectl > /usr/local/bin/kubectl +RUN curl -Lo go.tar.gz https://go.dev/dl/go1.20.2.linux-amd64.tar.gz +RUN tar -C /usr/local -xzf go.tar.gz +ENV PATH $PATH:/usr/local/go/bin +ENV PATH $PATH:/root/go +RUN go install sigs.k8s.io/kind@v0.17.0 +RUN git clone https://github.com/openconfig/kne.git +RUN cd kne && go install ./kne_cli && cp ~/go/bin/kne_cli ~/go/bin/kne \ No newline at end of file diff --git a/cloudbuild/kne.yaml b/cloudbuild/kne.yaml new file mode 100644 index 00000000..d124b8c6 --- /dev/null +++ b/cloudbuild/kne.yaml @@ -0,0 +1,5 @@ +steps: + - name: 'gcr.io/cloud-builders/docker' + args: [ 'build','--network=cloudbuild', '-t', 'gcr.io/openconfig-lemming/kne-kind', '-f', 'cloudbuild/Dockerfile', './cloudbuild' ] +images: + - 'gcr.io/openconfig-lemming/kne-kind' \ No newline at end of file diff --git a/cloudbuild/presubmit.sh b/cloudbuild/presubmit.sh index fa369406..572cd88b 100755 --- a/cloudbuild/presubmit.sh +++ b/cloudbuild/presubmit.sh @@ -19,10 +19,10 @@ set -xeE printf "\n apiServerPort: 6443" >> /kne-internal/kind/kind-no-cni.yaml sed -i "s/name: kne/name: kne\n recycle: true/g" /kne-internal/deploy/kne/kind-bridge.yaml -kne deploy /kne-internal/deploy/kne/kind-bridge.yaml || true +kne deploy ~/kne-internal/deploy/kne/kind-bridge.yaml || true mkdir -p ~/.kube kind get kubeconfig --internal --name kne > ~/.kube/config docker network connect kind "$(cat /etc/hostname)" -kne deploy /kne-internal/deploy/kne/kind-bridge.yaml +kne deploy ~/kne-internal/deploy/kne/kind-bridge.yaml make itest diff --git a/kne/deploy.sh b/kne/deploy.sh deleted file mode 100755 index 5e5cd9db..00000000 --- a/kne/deploy.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash -# Copyright 2022 Google LLC -# -# 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. - -set -e -cd "$(dirname "$0")" - -kne delete "$1" || true -cd .. -DOCKER_BUILDKIT=1 docker build . -f Dockerfile.lemming -t "lemming:latest" -kind load docker-image lemming:latest --name kne -cd - -kne create "$1" diff --git a/kne/setup.sh b/kne/setup.sh deleted file mode 100755 index 6c2ea3ef..00000000 --- a/kne/setup.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/bash -# Copyright 2022 Google LLC -# -# 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. - -set -e -cd "$(dirname "$0")" - -if ! which kne -then - go install github.com/openconfig/kne/kne_cli - mv "$HOME/go/bin/kne_cli" "$HOME/go/bin/kne" -fi - - -DIR=$(pwd) -cat > config.yaml << EOF -topology: $DIR/$1 -kubecfg: $HOME/.kube/config -cli: $(which kne) -username: foo -password: fake -EOF - -cd -