Skip to content

Commit 4fe5b66

Browse files
committed
Merge remote-tracking branch 'origin/main' into APL-940
2 parents 4eda29a + 4b58405 commit 4fe5b66

File tree

7 files changed

+120
-9
lines changed

7 files changed

+120
-9
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
wizApiToken:
2+
clientId: "__WIZ_CLIENT_ID__"
3+
clientToken: "__WIZ_CLIENT_TOKEN__"
4+
clientEndpoint: ""
5+
wiz-kubernetes-connector:
6+
enabled: true
7+
autoCreateConnector:
8+
connectorName: "<connectorName>"
9+
webhook:
10+
clusterExternalId: "<clusterExternalId>"
11+
wiz-admission-controller:
12+
enabled: true
13+
kubernetesAuditLogsWebhook:
14+
enabled: true
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
global:
2+
wizApiToken:
3+
clientId: "__WIZ_CLIENT_ID__"
4+
clientToken: "__WIZ_CLIENT_TOKEN__"
5+
clientEndpoint: ""
6+
7+
wiz-kubernetes-connector:
8+
enabled: true
9+
autoCreateConnector:
10+
connectorName: "<connectorName>"
11+
clusterExternalId: "<clusterExternalId>"
12+
wiz-broker:
13+
enabled: true
14+
15+
wiz-sensor:
16+
enabled: true
17+
imagePullSecret:
18+
create: false
19+
name: "sensor-image-pull"
20+
21+
wiz-admission-controller:
22+
enabled: true
23+
kubernetesAuditLogsWebhook:
24+
enabled: true
25+
opaWebhook:
26+
enabled: true
27+
imageIntegrityWebhook:
28+
enabled: false
29+
policies:
30+
- my-image-trust-policy

.github/workflows/integration.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,48 @@ jobs:
253253
sleep 10
254254
done
255255
echo LINODE_CLUSTER_CONTEXT=`kubectl config current-context` >> $GITHUB_ENV
256+
- name: Set up Wiz
257+
if: ${{ inputs.install_profile != 'no-apl' }}
258+
run: |
259+
260+
# Use cluster information from environment variables
261+
CLUSTER_NAME="${{ env.LINODE_CLUSTER_NAME }}"
262+
CLUSTER_ID="${{ env.LINODE_CLUSTER_ID }}"
263+
264+
echo "Setting up Wiz for cluster: $CLUSTER_NAME (ID: $CLUSTER_ID)"
265+
266+
# Create YAML configuration files from templates
267+
KUB_INTEGRATION_PATH="./${CLUSTER_NAME}_kub_integration.yaml"
268+
ADMISSION_PATH="./${CLUSTER_NAME}_admission_control.yaml"
269+
270+
sed "s/__WIZ_CLIENT_ID__/${{ secrets.WIZ_CLIENT_ID }}/g; s/__WIZ_CLIENT_TOKEN__/${{ secrets.WIZ_CLIENT_TOKEN }}/g; s/<connectorName>/${CLUSTER_NAME}/g; s/<clusterExternalId>/${CLUSTER_ID}/g" .github/templates/wiz-kubernetes-integration.yaml > "$KUB_INTEGRATION_PATH"
271+
sed "s/__WIZ_CLIENT_ID__/${{ secrets.WIZ_CLIENT_ID }}/g; s/__WIZ_CLIENT_TOKEN__/${{ secrets.WIZ_CLIENT_TOKEN }}/g; s/<connectorName>/${CLUSTER_NAME}/g; s/<clusterExternalId>/${CLUSTER_ID}/g" .github/templates/wiz-admission-control.yaml > "$ADMISSION_PATH"
272+
273+
# Verify cluster connectivity
274+
echo "Verifying cluster connectivity..."
275+
kubectl get nodes
276+
277+
# Add Helm repo for Wiz
278+
helm repo add wiz-sec https://charts.wiz.io/
279+
helm repo update
280+
281+
# Create namespace if not exists
282+
kubectl create namespace wiz --dry-run=client -o yaml | kubectl apply -f -
283+
284+
# Set release name
285+
RELEASE_NAME="wiz-${CLUSTER_NAME//_/-}"
286+
RELEASE_NAME="${RELEASE_NAME,,}" # Convert to lowercase
287+
NAMESPACE="wiz"
288+
289+
# Install Wiz components
290+
echo "🚀 Installing Wiz Kubernetes Integration..."
291+
helm install "$RELEASE_NAME" wiz-sec/wiz-kubernetes-integration --values "$KUB_INTEGRATION_PATH" -n "$NAMESPACE"
292+
293+
echo "🚀 Installing Wiz Admission Controller..."
294+
helm install wiz-lke-ac wiz-sec/wiz-admission-controller --values "$ADMISSION_PATH" -n "$NAMESPACE" --wait
295+
296+
echo "✅ Wiz deployment for cluster $CLUSTER_NAME completed."
297+
256298
- name: Create image pull secret on test cluster
257299
if: ${{ inputs.install_profile != 'no-apl' }}
258300
run: |

.values/.editorconfig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
root = true
2+
3+
[*]
4+
end_of_line = lf
5+
insert_final_newline = true
6+
trim_trailing_whitespace = true
7+
charset = utf-8
8+
indent_style = space
9+
indent_size = 2
10+
11+
[*.md]
12+
trim_trailing_whitespace = false
13+
14+
[env/**.{yaml,yaml.dec}]
15+
indent_size = 4

src/cmd/apply-as-apps.ts

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -92,27 +92,24 @@ const getArgocdAppManifest = (release: HelmRelease, values: Record<string, any>,
9292
const setFinalizers = async (name: string) => {
9393
d.info(`Setting finalizers for ${name}`)
9494
const resPatch =
95-
await $`kubectl -n argocd patch application ${name} -p '{"metadata": {"finalizers": ["resources-finalizer.argocd.argoproj.io"]}}' --type merge`
95+
await $`kubectl -n argocd patch applications.argoproj.io ${name} -p '{"metadata": {"finalizers": ["resources-finalizer.argocd.argoproj.io"]}}' --type merge`
9696
if (resPatch.exitCode !== 0) {
9797
throw new Error(`Failed to set finalizers for ${name}: ${resPatch.stderr}`)
9898
}
9999
}
100100

101101
const getFinalizers = async (name: string): Promise<string[]> => {
102-
const res = await $`kubectl -n argocd get application ${name} -o jsonpath='{.metadata.finalizers}'`
102+
const res = await $`kubectl -n argocd get applications.argoproj.io ${name} -o jsonpath='{.metadata.finalizers}'`
103103
return res.stdout ? JSON.parse(res.stdout) : []
104104
}
105105

106-
const removeApplication = async (release: HelmRelease): Promise<void> => {
107-
const name = getAppName(release)
108-
if (!(await isResourcePresent('application', name, 'argocd'))) return
109-
106+
const removeApplication = async (name: string): Promise<void> => {
110107
try {
111108
const finalizers = await getFinalizers(name)
112109
if (!finalizers.includes('resources-finalizer.argocd.argoproj.io')) {
113110
await setFinalizers(name)
114111
}
115-
const resDelete = await $`kubectl -n argocd delete application ${name}`
112+
const resDelete = await $`kubectl -n argocd delete applications.argoproj.io ${name}`
116113
d.info(resDelete.stdout.toString().trim())
117114
} catch (e) {
118115
d.error(`Failed to delete application ${name}: ${e.message}`)
@@ -149,6 +146,11 @@ async function patchArgocdResources(release: HelmRelease, values: Record<string,
149146
}
150147
}
151148

149+
const getApplications = async (): Promise<string[]> => {
150+
const res = await $`kubectl get application.argoproj.io -n argocd -oname`
151+
return res.stdout.split('\n')
152+
}
153+
152154
const writeApplicationManifest = async (release: HelmRelease, otomiVersion: string): Promise<void> => {
153155
const appName = `${release.namespace}-${release.name}`
154156
const applicationPath = `${appsDir}/${appName}.yaml`
@@ -186,6 +188,7 @@ export const applyAsApps = async (argv: HelmArguments): Promise<void> => {
186188
const errors: Array<any> = []
187189
// Generate JSON object with all helmfile releases defined in helmfile.d
188190
const releases: [] = JSON.parse(res.stdout.toString())
191+
const currentApplications = await getApplications()
189192
await Promise.allSettled(
190193
releases.map(async (release: HelmRelease) => {
191194
try {
@@ -197,7 +200,11 @@ export const applyAsApps = async (argv: HelmArguments): Promise<void> => {
197200

198201
if (release.installed) await writeApplicationManifest(release, otomiVersion)
199202
else {
200-
await removeApplication(release)
203+
const appName = getAppName(release)
204+
const resourceName = `application.argoproj.io/${appName}`
205+
if (currentApplications.includes(resourceName)) {
206+
await removeApplication(appName)
207+
}
201208
}
202209
} catch (e) {
203210
errors.push(e)

src/cmd/bootstrap.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ export const copyBasicFiles = async (
256256

257257
// force copy all these
258258
await Promise.allSettled(
259-
['.gitignore', '.prettierrc.yml', 'README.md'].map(async (val) =>
259+
['.editorconfig', '.gitignore', '.prettierrc.yml', 'README.md'].map(async (val) =>
260260
deps.copyFile(`${rootDir}/.values/${val}`, `${ENV_DIR}/${val}`),
261261
),
262262
)

src/server.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { hfValues } from './common/hf'
88
import { setValuesFile, unsetValuesFile } from './common/repo'
99
import { loadYaml, rootDir } from './common/utils'
1010
import { objectToYaml } from './common/values'
11+
import { copyFile } from 'fs/promises'
1112

1213
const d = terminal('server')
1314
const app = express()
@@ -42,6 +43,8 @@ app.get('/prepare', async (req: Request, res: Response): Promise<void> => {
4243
const { envDir, files } = req.query as QueryParams
4344
try {
4445
d.log('Request to prepare values repo on', envDir)
46+
const file = '.editorconfig'
47+
await copyFile(`${rootDir}/.values/${file}`, `${envDir}/${file}`)
4548
await bootstrapSops(envDir)
4649
await setValuesFile(envDir)
4750
// Encrypt ensures that a brand new secret file is encrypted in place

0 commit comments

Comments
 (0)