From 331ea63e76d37e1952679d81bdefc09d84ff17f2 Mon Sep 17 00:00:00 2001 From: Naga Ravi Chaitanya Elluri Date: Wed, 3 Jan 2024 23:55:33 -0500 Subject: [PATCH] Support Kubernetes specific container images This commit adds container files with just kubernetes client and removes the label as part of CNCF onboarding. Signed-off-by: Naga Ravi Chaitanya Elluri --- containers/Dockerfile | 6 +-- containers/Dockerfile-ppc64le | 4 +- containers/openshift/Dockerfile | 30 +++++++++++++++ containers/openshift/Dockerfile-ppc64le | 29 +++++++++++++++ containers/openshift/kraken.yml | 49 +++++++++++++++++++++++++ 5 files changed, 111 insertions(+), 7 deletions(-) create mode 100644 containers/openshift/Dockerfile create mode 100644 containers/openshift/Dockerfile-ppc64le create mode 100644 containers/openshift/kraken.yml diff --git a/containers/Dockerfile b/containers/Dockerfile index 5f2083372..a19494bd2 100644 --- a/containers/Dockerfile +++ b/containers/Dockerfile @@ -4,8 +4,6 @@ FROM mcr.microsoft.com/azure-cli:latest as azure-cli FROM registry.access.redhat.com/ubi8/ubi:latest -LABEL org.opencontainers.image.authors="Red Hat OpenShift Chaos Engineering" - ENV KUBECONFIG /root/.kube/config # Copy azure client binary from azure-cli image @@ -20,9 +18,9 @@ RUN yum install -y git python39 python3-pip jq gettext wget && \ pip3.9 install virtualenv && \ wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/bin/yq && chmod +x /usr/bin/yq -# Get Kubernetes and OpenShift clients from stable releases +# Setuo Kubernetes clients from stable releases WORKDIR /tmp -RUN wget https://mirror.openshift.com/pub/openshift-v4/clients/ocp/stable/openshift-client-linux.tar.gz && tar -xvf openshift-client-linux.tar.gz && cp oc /usr/local/bin/oc && cp kubectl /usr/local/bin/kubectl +RUN curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" && chmod +x kubectl && mv ./kubectl /usr/local/bin/kubectl WORKDIR /root/kraken diff --git a/containers/Dockerfile-ppc64le b/containers/Dockerfile-ppc64le index 7192b2801..a30ad10ed 100644 --- a/containers/Dockerfile-ppc64le +++ b/containers/Dockerfile-ppc64le @@ -4,8 +4,6 @@ FROM ppc64le/centos:8 FROM mcr.microsoft.com/azure-cli:latest as azure-cli -LABEL org.opencontainers.image.authors="Red Hat OpenShift Chaos Engineering" - ENV KUBECONFIG /root/.kube/config # Copy azure client binary from azure-cli image @@ -22,7 +20,7 @@ RUN yum install -y git python39 python3-pip jq gettext wget && \ # Get Kubernetes and OpenShift clients from stable releases WORKDIR /tmp -RUN wget https://mirror.openshift.com/pub/openshift-v4/clients/ocp/stable/openshift-client-linux.tar.gz && tar -xvf openshift-client-linux.tar.gz && cp oc /usr/local/bin/oc && cp kubectl /usr/local/bin/kubectl +RUN curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" && chmod +x kubectl && mv ./kubectl /usr/local/bin/kubectl WORKDIR /root/kraken diff --git a/containers/openshift/Dockerfile b/containers/openshift/Dockerfile new file mode 100644 index 000000000..5f2083372 --- /dev/null +++ b/containers/openshift/Dockerfile @@ -0,0 +1,30 @@ +# Dockerfile for kraken + +FROM mcr.microsoft.com/azure-cli:latest as azure-cli + +FROM registry.access.redhat.com/ubi8/ubi:latest + +LABEL org.opencontainers.image.authors="Red Hat OpenShift Chaos Engineering" + +ENV KUBECONFIG /root/.kube/config + +# Copy azure client binary from azure-cli image +COPY --from=azure-cli /usr/local/bin/az /usr/bin/az + +# Install dependencies +RUN yum install -y git python39 python3-pip jq gettext wget && \ + python3.9 -m pip install -U pip && \ + git clone https://github.com/redhat-chaos/krkn.git --branch v1.5.2 /root/kraken && \ + mkdir -p /root/.kube && cd /root/kraken && \ + pip3.9 install -r requirements.txt && \ + pip3.9 install virtualenv && \ + wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/bin/yq && chmod +x /usr/bin/yq + +# Get Kubernetes and OpenShift clients from stable releases +WORKDIR /tmp +RUN wget https://mirror.openshift.com/pub/openshift-v4/clients/ocp/stable/openshift-client-linux.tar.gz && tar -xvf openshift-client-linux.tar.gz && cp oc /usr/local/bin/oc && cp kubectl /usr/local/bin/kubectl + +WORKDIR /root/kraken + +ENTRYPOINT ["python3.9", "run_kraken.py"] +CMD ["--config=config/config.yaml"] diff --git a/containers/openshift/Dockerfile-ppc64le b/containers/openshift/Dockerfile-ppc64le new file mode 100644 index 000000000..7192b2801 --- /dev/null +++ b/containers/openshift/Dockerfile-ppc64le @@ -0,0 +1,29 @@ +# Dockerfile for kraken + +FROM ppc64le/centos:8 + +FROM mcr.microsoft.com/azure-cli:latest as azure-cli + +LABEL org.opencontainers.image.authors="Red Hat OpenShift Chaos Engineering" + +ENV KUBECONFIG /root/.kube/config + +# Copy azure client binary from azure-cli image +COPY --from=azure-cli /usr/local/bin/az /usr/bin/az + +# Install dependencies +RUN yum install -y git python39 python3-pip jq gettext wget && \ + python3.9 -m pip install -U pip && \ + git clone https://github.com/redhat-chaos/krkn.git --branch v1.5.2 /root/kraken && \ + mkdir -p /root/.kube && cd /root/kraken && \ + pip3.9 install -r requirements.txt && \ + pip3.9 install virtualenv && \ + wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/bin/yq && chmod +x /usr/bin/yq + +# Get Kubernetes and OpenShift clients from stable releases +WORKDIR /tmp +RUN wget https://mirror.openshift.com/pub/openshift-v4/clients/ocp/stable/openshift-client-linux.tar.gz && tar -xvf openshift-client-linux.tar.gz && cp oc /usr/local/bin/oc && cp kubectl /usr/local/bin/kubectl + +WORKDIR /root/kraken + +ENTRYPOINT python3.9 run_kraken.py --config=config/config.yaml diff --git a/containers/openshift/kraken.yml b/containers/openshift/kraken.yml new file mode 100644 index 000000000..fecc682fe --- /dev/null +++ b/containers/openshift/kraken.yml @@ -0,0 +1,49 @@ +--- +apiVersion: batch/v1 +kind: Job +metadata: + name: kraken +spec: + parallelism: 1 + completions: 1 + template: + metadata: + labels: + tool: Kraken + spec: + serviceAccountName: useroot + containers: + - name: kraken + securityContext: + privileged: true + image: quay.io/redhat-chaos/krkn + command: ["/bin/sh", "-c"] + args: ["python3.9 run_kraken.py -c config/config.yaml"] + volumeMounts: + - mountPath: "/root/.kube" + name: config + - mountPath: "/root/kraken/config" + name: kraken-config + - mountPath: "/root/kraken/scenarios" + name: scenarios-config + - mountPath: "/root/kraken/scenarios/openshift" + name: scenarios-openshift-config + - mountPath: "/root/kraken/scenarios/kube" + name: scenarios-kube-config + restartPolicy: Never + volumes: + - name: config + configMap: + name: kube-config + - name: kraken-config + configMap: + name: kraken-config + - name: scenarios-config + configMap: + name: scenarios-config + - name: scenarios-openshift-config + configMap: + name: scenarios-openshift-config + - name: scenarios-kube-config + configMap: + name: scenarios-kube-config