Skip to content

Commit

Permalink
Merge branch 'main' into K8SPS-317
Browse files Browse the repository at this point in the history
  • Loading branch information
hors authored Dec 19, 2023
2 parents c0db51e + 216f486 commit 362baea
Show file tree
Hide file tree
Showing 69 changed files with 192 additions and 193 deletions.
4 changes: 2 additions & 2 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
* @hors @egegunes @inelpandzic @pooknull
/e2e-tests/ @tplavcic @nmarukovich @cap1984
Jenkinsfile @tplavcic @nmarukovich @cap1984
/e2e-tests/ @tplavcic @nmarukovich @ptankov
Jenkinsfile @tplavcic @nmarukovich @ptankov
12 changes: 6 additions & 6 deletions .github/workflows/reviewdog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
- uses: actions/setup-go@v4
with:
go-version: '^1.20'
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
Expand All @@ -21,7 +21,7 @@ jobs:
name: runner / suggester / gofmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- run: gofmt -w -s $(find . -not -path "*/vendor/*" -name "*.go")
- uses: reviewdog/action-suggester@v1
with:
Expand All @@ -31,7 +31,7 @@ jobs:
name: runner / suggester / shfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: '^1.17'
Expand All @@ -47,7 +47,7 @@ jobs:
name: runner / shellcheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: reviewdog/action-shellcheck@v1
with:
github_token: ${{ secrets.github_token }}
Expand All @@ -59,7 +59,7 @@ jobs:
name: runner / misspell
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: reviewdog/action-misspell@v1
with:
github_token: ${{ secrets.github_token }}
Expand All @@ -71,7 +71,7 @@ jobs:
name: runner / alex
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: reviewdog/action-alex@v1
with:
github_token: ${{ secrets.github_token }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Build an image from Dockerfile
run: |
export IMAGE=perconalab/percona-server-mysql-operator:${{ github.sha }}
export DOCKER_PUSH=0
export DOCKER_SQUASH=0
./e2e-tests/build
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@0.11.2
uses: aquasecurity/trivy-action@0.13.1
with:
image-ref: 'docker.io/perconalab/percona-server-mysql-operator:${{ github.sha }}'
format: 'table'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Clone the code
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v4
with:
Expand Down
91 changes: 39 additions & 52 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
GKERegion="us-central1-a"
region="us-central1-a"
testUrlPrefix="https://percona-jenkins-artifactory-public.s3.amazonaws.com/cloud-ps-operator"
tests=[]

Expand All @@ -7,21 +7,19 @@ void createCluster(String CLUSTER_SUFFIX, String SUBNETWORK = CLUSTER_SUFFIX) {
sh """
NODES_NUM=3
export KUBECONFIG=/tmp/$CLUSTER_NAME-${CLUSTER_SUFFIX}
export USE_GKE_GCLOUD_AUTH_PLUGIN=True
source $HOME/google-cloud-sdk/path.bash.inc
ret_num=0
while [ \${ret_num} -lt 15 ]; do
ret_val=0
gcloud auth activate-service-account --key-file $CLIENT_SECRET_FILE
gcloud config set project $GCP_PROJECT
gcloud container clusters list --filter $CLUSTER_NAME-${CLUSTER_SUFFIX} --zone $GKERegion --format='csv[no-heading](name)' | xargs gcloud container clusters delete --zone $GKERegion --quiet || true
gcloud container clusters create --zone $GKERegion $CLUSTER_NAME-${CLUSTER_SUFFIX} --cluster-version=1.24 --machine-type=n1-standard-4 --preemptible --num-nodes=\$NODES_NUM --network=jenkins-ps-vpc --subnetwork=jenkins-ps-${SUBNETWORK} --no-enable-autoupgrade --cluster-ipv4-cidr=/21 --labels delete-cluster-after-hours=6 && \
gcloud container clusters list --filter $CLUSTER_NAME-${CLUSTER_SUFFIX} --zone $region --format='csv[no-heading](name)' | xargs gcloud container clusters delete --zone $region --quiet || true
gcloud container clusters create --zone $region $CLUSTER_NAME-${CLUSTER_SUFFIX} --cluster-version=1.25 --machine-type=n1-standard-4 --preemptible --num-nodes=\$NODES_NUM --network=jenkins-ps-vpc --subnetwork=jenkins-ps-${SUBNETWORK} --no-enable-autoupgrade --cluster-ipv4-cidr=/21 --labels delete-cluster-after-hours=6 && \
kubectl create clusterrolebinding cluster-admin-binding --clusterrole cluster-admin --user jenkins@"$GCP_PROJECT".iam.gserviceaccount.com || ret_val=\$?
if [ \${ret_val} -eq 0 ]; then break; fi
ret_num=\$((ret_num + 1))
done
if [ \${ret_num} -eq 15 ]; then
gcloud container clusters list --filter $CLUSTER_NAME-${CLUSTER_SUFFIX} --zone $GKERegion --format='csv[no-heading](name)' | xargs gcloud container clusters delete --zone $GKERegion --quiet || true
gcloud container clusters list --filter $CLUSTER_NAME-${CLUSTER_SUFFIX} --zone $region --format='csv[no-heading](name)' | xargs gcloud container clusters delete --zone $region --quiet || true
exit 1
fi
"""
Expand All @@ -32,8 +30,6 @@ void shutdownCluster(String CLUSTER_SUFFIX) {
withCredentials([string(credentialsId: 'GCP_PROJECT_ID', variable: 'GCP_PROJECT'), file(credentialsId: 'gcloud-key-file', variable: 'CLIENT_SECRET_FILE')]) {
sh """
export KUBECONFIG=/tmp/$CLUSTER_NAME-${CLUSTER_SUFFIX}
export USE_GKE_GCLOUD_AUTH_PLUGIN=True
source $HOME/google-cloud-sdk/path.bash.inc
gcloud auth activate-service-account --key-file $CLIENT_SECRET_FILE
gcloud config set project $GCP_PROJECT
for namespace in \$(kubectl get namespaces --no-headers | awk '{print \$1}' | grep -vE "^kube-|^openshift" | sed '/-operator/ s/^/1-/' | sort | sed 's/^1-//'); do
Expand All @@ -45,17 +41,15 @@ void shutdownCluster(String CLUSTER_SUFFIX) {
kubectl delete pods --all -n \$namespace --force --grace-period=0 || true
done
kubectl get svc --all-namespaces || true
gcloud container clusters delete --zone $GKERegion $CLUSTER_NAME-${CLUSTER_SUFFIX}
gcloud container clusters delete --zone $region $CLUSTER_NAME-${CLUSTER_SUFFIX}
"""
}
}

void deleteOldClusters(String FILTER) {
withCredentials([string(credentialsId: 'GCP_PROJECT_ID', variable: 'GCP_PROJECT'), file(credentialsId: 'gcloud-key-file', variable: 'CLIENT_SECRET_FILE')]) {
sh """
if [ -f $HOME/google-cloud-sdk/path.bash.inc ]; then
export USE_GKE_GCLOUD_AUTH_PLUGIN=True
source $HOME/google-cloud-sdk/path.bash.inc
if gcloud --version > /dev/null 2>&1; then
gcloud auth activate-service-account --key-file $CLIENT_SECRET_FILE
gcloud config set project $GCP_PROJECT
for GKE_CLUSTER in \$(gcloud container clusters list --format='csv[no-heading](name)' --filter="$FILTER"); do
Expand All @@ -71,7 +65,7 @@ void deleteOldClusters(String FILTER) {
break
fi
done
gcloud container clusters delete --async --zone $GKERegion --quiet \$GKE_CLUSTER || true
gcloud container clusters delete --async --zone $region --quiet \$GKE_CLUSTER || true
done
fi
"""
Expand Down Expand Up @@ -207,8 +201,7 @@ void runTest(Integer TEST_ID) {
mkdir "e2e-tests/logs"
fi
export KUBECONFIG=/tmp/$CLUSTER_NAME-$clusterSuffix
export PATH="$HOME/.krew/bin:$PATH"
source $HOME/google-cloud-sdk/path.bash.inc
export PATH="\${KREW_ROOT:-\$HOME/.krew}/bin:\$PATH"
set -o pipefail
kubectl kuttl test --config ./e2e-tests/kuttl.yaml --test "^${testName}\$" |& tee e2e-tests/logs/${testName}.log
"""
Expand Down Expand Up @@ -237,46 +230,41 @@ void runTest(Integer TEST_ID) {
}

void prepareNode() {
sh '''
sudo yum install -y https://repo.percona.com/yum/percona-release-latest.noarch.rpm || true
sudo percona-release enable-only tools
sudo yum install -y percona-xtrabackup-80 | true
'''

sh '''
if [ ! -d $HOME/google-cloud-sdk/bin ]; then
rm -rf $HOME/google-cloud-sdk
curl https://sdk.cloud.google.com | bash
fi
source $HOME/google-cloud-sdk/path.bash.inc
gcloud components install alpha
gcloud components install kubectl
curl -fsSL https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash
curl -s -L https://github.com/openshift/origin/releases/download/v3.11.0/openshift-origin-client-tools-v3.11.0-0cbc58b-linux-64bit.tar.gz \
| sudo tar -C /usr/local/bin --strip-components 1 --wildcards -zxvpf - '*/oc'
curl -s -L https://github.com/mitchellh/golicense/releases/latest/download/golicense_0.2.0_linux_x86_64.tar.gz \
| sudo tar -C /usr/local/bin --wildcards -zxvpf -
sudo sh -c "curl -s -L https://github.com/mikefarah/yq/releases/download/v4.34.1/yq_linux_amd64 > /usr/local/bin/yq"
sh """
sudo curl -s -L -o /usr/local/bin/kubectl https://dl.k8s.io/release/\$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl && sudo chmod +x /usr/local/bin/kubectl
kubectl version --client --output=yaml
curl -fsSL https://get.helm.sh/helm-v3.12.3-linux-amd64.tar.gz | sudo tar -C /usr/local/bin --strip-components 1 -xzf - linux-amd64/helm
sudo sh -c "curl -s -L https://github.com/mikefarah/yq/releases/download/v4.35.1/yq_linux_amd64 > /usr/local/bin/yq"
sudo chmod +x /usr/local/bin/yq
sudo sh -c "curl -s -L https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64 > /usr/local/bin/jq"
sudo sh -c "curl -s -L https://github.com/jqlang/jq/releases/download/jq-1.6/jq-linux64 > /usr/local/bin/jq"
sudo chmod +x /usr/local/bin/jq
cd "$(mktemp -d)"
OS="$(uname | tr '[:upper:]' '[:lower:]')"
ARCH="$(uname -m | sed -e 's/x86_64/amd64/')"
KREW="krew-${OS}_${ARCH}"
curl -fsSLO "https://github.com/kubernetes-sigs/krew/releases/download/v0.4.3/${KREW}.tar.gz"
tar zxvf "${KREW}.tar.gz"
./"${KREW}" install krew
rm -f "${KREW}.tar.gz"
export PATH="${KREW_ROOT:-$HOME/.krew}/bin:$PATH"
curl -fsSL https://github.com/kubernetes-sigs/krew/releases/latest/download/krew-linux_amd64.tar.gz | tar -xzf -
./krew-linux_amd64 install krew
export PATH="\${KREW_ROOT:-\$HOME/.krew}/bin:\$PATH"
kubectl krew install assert
# v0.15.0 kuttl version
kubectl krew install --manifest-url https://raw.githubusercontent.com/kubernetes-sigs/krew-index/a67f31ecb2e62f15149ca66d096357050f07b77d/plugins/kuttl.yaml
printf "%s is installed" "$(kubectl kuttl --version)"
kubectl krew install assert
'''
echo \$(kubectl kuttl --version) is installed
sudo tee /etc/yum.repos.d/google-cloud-sdk.repo << EOF
[google-cloud-cli]
name=Google Cloud CLI
baseurl=https://packages.cloud.google.com/yum/repos/cloud-sdk-el7-x86_64
enabled=1
gpgcheck=1
repo_gpgcheck=0
gpgkey=https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
EOF
sudo yum install -y google-cloud-cli google-cloud-cli-gke-gcloud-auth-plugin
curl -sL https://github.com/mitchellh/golicense/releases/latest/download/golicense_0.2.0_linux_x86_64.tar.gz | sudo tar -C /usr/local/bin -xzf - golicense
"""
}

def skipBranchBuilds = true
Expand Down Expand Up @@ -570,9 +558,8 @@ pipeline {
}
deleteOldClusters("$CLUSTER_NAME")
sh """
sudo docker system prune -fa
sudo rm -rf ./*
sudo rm -rf $HOME/google-cloud-sdk
sudo docker system prune --volumes -af
sudo rm -rf *
"""
deleteDir()
}
Expand Down
Loading

0 comments on commit 362baea

Please sign in to comment.