Skip to content

Commit eea6e6c

Browse files
authored
Revert "Consolidate on-prem-installer deb packages (#363)" (#501)
1 parent 178859f commit eea6e6c

File tree

17 files changed

+751
-583
lines changed

17 files changed

+751
-583
lines changed

on-prem-installers/cmd/onprem-argo-cd/after-install.sh

Lines changed: 4 additions & 132 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,6 @@
66

77
set -o errexit
88

9-
export KUBECONFIG=/home/$USER/.kube/config
10-
11-
# Add /usr/local/bin to the PATH as some utilities, like kubectl, could be installed there
12-
export PATH=$PATH:/usr/local/bin
13-
14-
IMAGE_REGISTRY="${IMAGE_REGISTRY:-docker.io}"
15-
16-
install_argocd() {
179
cat << "EOF"
1810
1911
_ ____ ____
@@ -25,6 +17,10 @@ cat << "EOF"
2517
2618
EOF
2719

20+
export KUBECONFIG=/home/$USER/.kube/config
21+
22+
# Add /usr/local/bin to the PATH as some utilities, like kubectl, could be installed there
23+
export PATH=$PATH:/usr/local/bin
2824

2925
cp /tmp/argo-cd/values.tmpl /tmp/argo-cd/argo-cd/templates/values.tmpl
3026
# helm treats comma as separator in '--set' command, so multiple no_proxy values are treated as different env values, so we have to write them to file first
@@ -92,127 +88,3 @@ applicationSet:
9288
path: /usr/local/share/ca-certificates/gitea_cert.crt
9389
" > /tmp/argo-cd/mounts.yaml
9490
helm install argocd /tmp/argo-cd/argo-cd --values /tmp/argo-cd/values.yaml -f /tmp/argo-cd/mounts.yaml -n argocd --create-namespace
95-
}
96-
97-
98-
processSAN() {
99-
local result="subjectAltName=DNS:localhost"
100-
for domain in "$@"; do
101-
result="${result},DNS:${domain}"
102-
done
103-
echo "${result}"
104-
}
105-
106-
processCerts() {
107-
echo "Generating key..."
108-
109-
if ! openssl version; then
110-
echo "OpenSSL not found!"
111-
exit 1
112-
fi
113-
114-
openssl="openssl"
115-
116-
tmpDir=$(mktemp -d)
117-
$openssl genrsa -out "$tmpDir/infra-tls.key" 4096
118-
119-
echo "Generating certificate..."
120-
san=$(processSAN "$@")
121-
# Generate the certificate with the name infra-tls.crt
122-
$openssl req -key "$tmpDir/infra-tls.key" -new -x509 -days 365 -out "$tmpDir/infra-tls.crt" -subj "/C=US/O=Orch Deploy/OU=Orchestrator" -addext "$san"
123-
cp "${tmpDir}"/infra-tls.crt /usr/local/share/ca-certificates/gitea_cert.crt
124-
update-ca-certificates
125-
126-
# Create a tls secret with custom key names
127-
kubectl create secret tls gitea-tls-certs -n gitea \
128-
--cert="$tmpDir/infra-tls.crt" \
129-
--key="$tmpDir/infra-tls.key"
130-
131-
# Clean up the temporary directory
132-
rm -rf "$tmpDir"
133-
}
134-
135-
randomPassword() {
136-
tr -dc A-Za-z0-9 </dev/urandom | head -c 16
137-
}
138-
139-
createGiteaSecret() {
140-
local secretName=$1
141-
local accountName=$2
142-
local password=$3
143-
local namespace=$4
144-
145-
kubectl create secret generic "$secretName" -n "$namespace" \
146-
--from-literal=username="$accountName" \
147-
--from-literal=password="$password" \
148-
--dry-run=client -o yaml | kubectl apply -f -
149-
}
150-
151-
createGiteaAccount() {
152-
local secretName=$1
153-
local accountName=$2
154-
local password=$3
155-
local email=$4
156-
local giteaPods=""
157-
local giteaPod=""
158-
159-
giteaPods=$(kubectl get pods -n gitea -l app=gitea -o jsonpath="{.items[*].metadata.name}")
160-
if [ -z "$giteaPods" ]; then
161-
echo "No Gitea pods found. Exiting."
162-
exit 1
163-
fi
164-
165-
giteaPod=$(echo "$giteaPods" | cut -d ' ' -f1)
166-
if ! kubectl exec -n gitea "$giteaPod" -c "gitea" -- gitea admin user list | grep -q "$accountName"; then
167-
echo "Creating Gitea account for $accountName"
168-
kubectl exec -n gitea "$giteaPod" -c "gitea" -- gitea admin user create --username "$accountName" --password "$password" --email "$email" --must-change-password=false
169-
else
170-
echo "Gitea account for $accountName already exists, updating password"
171-
kubectl exec -n gitea "$giteaPod" -c "gitea" -- gitea admin user change-password --username "$accountName" --password "$password" --must-change-password=false
172-
fi
173-
174-
userToken=$(kubectl exec -n gitea "$giteaPod" -c gitea -- gitea admin user generate-access-token --scopes write:repository,write:user --username $accountName --token-name "${accountName}-$(date +%s)")
175-
token=$(echo $userToken | awk '{print $NF}')
176-
kubectl create secret generic gitea-$accountName-token -n gitea --from-literal=token=$token
177-
}
178-
179-
install_gitea() {
180-
cat << "EOF"
181-
182-
____ _ _
183-
/ ___(_) |_ ___ __ _
184-
| | _| | __/ _ \/ _` |
185-
| |_| | | || __/ (_| |
186-
\____|_|\__\___|\__,_|
187-
188-
189-
EOF
190-
191-
kubectl create ns gitea >/dev/null 2>&1 || true
192-
kubectl create ns orch-platform >/dev/null 2>&1 || true
193-
kubectl -n gitea get secret gitea-tls-certs >/dev/null 2>&1 || processCerts gitea-http.gitea.svc.cluster.local
194-
195-
adminGiteaPassword=$(randomPassword)
196-
argocdGiteaPassword=$(randomPassword)
197-
appGiteaPassword=$(randomPassword)
198-
clusterGiteaPassword=$(randomPassword)
199-
200-
# Create secret for Gitea admin user but should not be used for normal operations
201-
createGiteaSecret "gitea-cred" "gitea_admin" "$adminGiteaPassword" "gitea"
202-
203-
# Create user credential secrets for ArgoCD, AppOrch and ClusterOrch
204-
createGiteaSecret "argocd-gitea-credential" "argocd" "$argocdGiteaPassword" "gitea"
205-
createGiteaSecret "app-gitea-credential" "apporch" "$appGiteaPassword" "orch-platform"
206-
createGiteaSecret "cluster-gitea-credential" "clusterorch" "$clusterGiteaPassword" "orch-platform"
207-
208-
# More helm values are set in ../assets/gitea/values.yaml
209-
helm install gitea /tmp/gitea/gitea --values /tmp/gitea/values.yaml --set gitea.admin.existingSecret=gitea-cred --set image.registry="${IMAGE_REGISTRY}" -n gitea --timeout 15m0s --wait
210-
211-
# Create Gitea accounts for ArgoCD, AppOrch and ClusterOrch
212-
createGiteaAccount "argocd-gitea-credential" "argocd" "$argocdGiteaPassword" "[email protected]"
213-
createGiteaAccount "app-gitea-credential" "apporch" "$appGiteaPassword" "[email protected]"
214-
createGiteaAccount "cluster-gitea-credential" "clusterorch" "$clusterGiteaPassword" "[email protected]"
215-
}
216-
217-
install_gitea
218-
install_argocd

on-prem-installers/cmd/onprem-argo-cd/after-remove.sh

Lines changed: 11 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,6 @@
66

77
set -o errexit
88

9-
export KUBECONFIG=/home/$USER/.kube/config
10-
11-
# Add /usr/local/bin to the PATH as some utilities, like kubectl, could be installed there
12-
export PATH=$PATH:/usr/local/bin
13-
14-
remove_argocd() {
15-
169
cat << "EOF"
1710
1811
_ ____ ____ ____
@@ -24,37 +17,18 @@ cat << "EOF"
2417
2518
EOF
2619

27-
# If ArgoCD is upgraded its helm chart shouldn't be deleted, as helm upgrade
28-
# will be called in after-upgrade
29-
if [ "${1}" = "upgrade" ]; then
30-
return 0
31-
fi
32-
33-
helm delete argocd -n argocd || true
34-
35-
# Remove artifacts
36-
rm -rf /tmp/argo-cd || true
37-
}
38-
39-
40-
41-
remove_gitea() {
42-
cat << "EOF"
43-
44-
____ _ _ ____
45-
/ ___(_) |_ ___ __ _ | _ \ ___ _ __ ___ _____ _____
46-
| | _| | __/ _ \/ _` | | |_) / _ \ '_ ` _ \ / _ \ \ / / _ \
47-
| |_| | | || __/ (_| | | _ < __/ | | | | | (_) \ V / __/
48-
\____|_|\__\___|\__,_| |_| \_\___|_| |_| |_|\___/ \_/ \___|
20+
# If ArgoCD is upgraded its helm chart shouldn't be deleted, as helm upgrade
21+
# will be called in after-upgrade
22+
if [ "${1}" = "upgrade" ]; then
23+
exit 0
24+
fi
4925

26+
export KUBECONFIG=/home/$USER/.kube/config
5027

51-
EOF
28+
# Add /usr/local/bin to the PATH as some utilities, like kubectl, could be installed there
29+
export PATH=$PATH:/usr/local/bin
5230

53-
helm delete gitea -n gitea || true
54-
kubectl delete secret gitea-cred gitea-tls-certs gitea-token -n gitea || true
55-
# clean the certificate on the system
56-
rm -f /usr/local/share/ca-certificates/gitea_cert.crt || true
57-
}
31+
helm delete argocd -n argocd || true
5832

59-
remove_gitea
60-
remove_argocd
33+
# Remove artifacts
34+
rm -rf /tmp/argo-cd || true

on-prem-installers/cmd/onprem-argo-cd/after-upgrade.sh

Lines changed: 4 additions & 133 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,6 @@
66

77
set -o errexit
88

9-
10-
export KUBECONFIG=/home/$USER/.kube/config
11-
12-
# Add /usr/local/bin to the PATH as some utilities, like kubectl, could be installed there
13-
export PATH=$PATH:/usr/local/bin
14-
IMAGE_REGISTRY="${IMAGE_REGISTRY:-docker.io}"
15-
16-
upgrade_argocd() {
17-
189
cat << "EOF"
1910
2011
_ ____ ____ _ _ _
@@ -26,6 +17,10 @@ cat << "EOF"
2617
2718
EOF
2819

20+
export KUBECONFIG=/home/$USER/.kube/config
21+
22+
# Add /usr/local/bin to the PATH as some utilities, like kubectl, could be installed there
23+
export PATH=$PATH:/usr/local/bin
2924

3025
cp /tmp/argo-cd/values.tmpl /tmp/argo-cd/argo-cd/templates/values.tmpl
3126
# helm treats comma as separator in '--set' command, so multiple no_proxy values are treated as different env values, so we have to write them to file first
@@ -96,127 +91,3 @@ applicationSet:
9691
echo "ArgoCD Helm Chart is being upgraded, please wait, timeout is set to 10m..."
9792
helm upgrade argocd /tmp/argo-cd/argo-cd --values /tmp/argo-cd/values.yaml -f /tmp/argo-cd/mounts.yaml -n argocd \
9893
--wait --timeout 15m0s
99-
}
100-
101-
102-
processSAN() {
103-
local result="subjectAltName=DNS:localhost"
104-
for domain in "$@"; do
105-
result="${result},DNS:${domain}"
106-
done
107-
echo "${result}"
108-
}
109-
110-
processCerts() {
111-
echo "Generating key..."
112-
113-
if ! openssl version; then
114-
echo "OpenSSL not found!"
115-
exit 1
116-
fi
117-
118-
openssl="openssl"
119-
120-
tmpDir=$(mktemp -d)
121-
$openssl genrsa -out "$tmpDir/infra-tls.key" 4096
122-
123-
echo "Generating certificate..."
124-
san=$(processSAN "$@")
125-
# Generate the certificate with the name infra-tls.crt
126-
$openssl req -key "$tmpDir/infra-tls.key" -new -x509 -days 365 -out "$tmpDir/infra-tls.crt" -subj "/C=US/O=Orch Deploy/OU=Open Edge Platform" -addext "$san"
127-
cp "${tmpDir}"/infra-tls.crt /usr/local/share/ca-certificates/gitea_cert.crt
128-
update-ca-certificates
129-
130-
# Create a tls secret with custom key names
131-
kubectl create secret tls gitea-tls-certs -n gitea \
132-
--cert="$tmpDir/infra-tls.crt" \
133-
--key="$tmpDir/infra-tls.key"
134-
135-
# Clean up the temporary directory
136-
rm -rf "$tmpDir"
137-
}
138-
139-
randomPassword() {
140-
tr -dc A-Za-z0-9 </dev/urandom | head -c 16
141-
}
142-
143-
createGiteaSecret() {
144-
local secretName=$1
145-
local accountName=$2
146-
local password=$3
147-
local namespace=$4
148-
149-
kubectl create secret generic "$secretName" -n "$namespace" \
150-
--from-literal=username="$accountName" \
151-
--from-literal=password="$password" \
152-
--dry-run=client -o yaml | kubectl apply -f -
153-
}
154-
155-
createGiteaAccount() {
156-
local secretName=$1
157-
local accountName=$2
158-
local password=$3
159-
local email=$4
160-
local giteaPods=""
161-
local giteaPod=""
162-
163-
giteaPods=$(kubectl get pods -n gitea -l app=gitea -o jsonpath="{.items[*].metadata.name}")
164-
if [ -z "$giteaPods" ]; then
165-
echo "No Gitea pods found. Exiting."
166-
exit 1
167-
fi
168-
169-
giteaPod=$(echo "$giteaPods" | cut -d ' ' -f1)
170-
if ! kubectl exec -n gitea "$giteaPod" -c gitea -- gitea admin user list | grep -q "$accountName"; then
171-
echo "Creating Gitea account for $accountName"
172-
kubectl exec -n gitea "$giteaPod" -c gitea -- gitea admin user create --username "$accountName" --password "$password" --email "$email" --must-change-password=false
173-
else
174-
echo "Gitea account for $accountName already exists, updating password"
175-
kubectl exec -n gitea "$giteaPod" -c gitea -- gitea admin user change-password --username "$accountName" --password "$password" --must-change-password=false
176-
fi
177-
178-
userToken=$(kubectl exec -n gitea "$giteaPod" -c gitea -- gitea admin user generate-access-token --scopes write:repository,write:user --username "$accountName" --token-name "${accountName}-$(date +%s)")
179-
token=$(echo "$userToken" | awk '{print $NF}')
180-
kubectl create secret generic gitea-"$accountName"-token -n gitea --from-literal=token="$token"
181-
}
182-
183-
upgrade_gitea() {
184-
cat << "EOF"
185-
186-
____ _ _ _ _ _
187-
/ ___(_) |_ ___ __ _ | | | |_ __ __ _ _ __ __ _ __| | ___
188-
| | _| | __/ _ \/ _` | | | | | '_ \ / _` | '__/ _` |/ _` |/ _ \
189-
| |_| | | || __/ (_| | | |_| | |_) | (_| | | | (_| | (_| | __/
190-
\____|_|\__\___|\__,_| \___/| .__/ \__, |_| \__,_|\__,_|\___|
191-
|_| |___/
192-
193-
EOF
194-
195-
kubectl create ns gitea >/dev/null 2>&1 || true
196-
kubectl create ns orch-platform >/dev/null 2>&1 || true
197-
kubectl -n gitea get secret gitea-tls-certs >/dev/null 2>&1 || processCerts gitea-http.gitea.svc.cluster.local
198-
199-
adminGiteaPassword=$(randomPassword)
200-
argocdGiteaPassword=$(randomPassword)
201-
appGiteaPassword=$(randomPassword)
202-
clusterGiteaPassword=$(randomPassword)
203-
204-
# Create secret for Gitea admin user but should not be used for normal operations
205-
createGiteaSecret "gitea-cred" "gitea_admin" "$adminGiteaPassword" "gitea"
206-
207-
# Create user credential secrets for ArgoCD, AppOrch and ClusterOrch
208-
createGiteaSecret "argocd-gitea-credential" "argocd" "$argocdGiteaPassword" "gitea"
209-
createGiteaSecret "app-gitea-credential" "apporch" "$appGiteaPassword" "orch-platform"
210-
createGiteaSecret "cluster-gitea-credential" "clusterorch" "$clusterGiteaPassword" "orch-platform"
211-
212-
# More helm values are set in ../assets/gitea/values.yaml
213-
helm upgrade --install gitea /tmp/gitea/gitea --values /tmp/gitea/values.yaml --set gitea.admin.existingSecret=gitea-cred --set image.registry="${IMAGE_REGISTRY}" -n gitea --timeout 15m0s --wait
214-
215-
# Create Gitea accounts for ArgoCD, AppOrch and ClusterOrch
216-
createGiteaAccount "argocd-gitea-credential" "argocd" "$argocdGiteaPassword" "[email protected]"
217-
createGiteaAccount "app-gitea-credential" "apporch" "$appGiteaPassword" "[email protected]"
218-
createGiteaAccount "cluster-gitea-credential" "clusterorch" "$clusterGiteaPassword" "[email protected]"
219-
}
220-
221-
upgrade_gitea
222-
upgrade_argocd
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env bash
2+
3+
# SPDX-FileCopyrightText: 2025 Intel Corporation
4+
#
5+
# SPDX-License-Identifier: Apache-2.0
6+
7+
set -o errexit
8+
9+
# Add /usr/local/bin to the PATH as some utilities, like kubectl, could be installed there
10+
export PATH=$PATH:/usr/local/bin
11+
12+
# Execute the installer with the current directory as context
13+
/usr/bin/onprem-config-installer

0 commit comments

Comments
 (0)