Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Infrastructure GitOps
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Operate
Terraform modules
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Shivering-Isles
Infrastructure GitOps
Commits
4526f7b0
Verified
Commit
4526f7b0
authored
3 years ago
by
Sheogorath
Browse files
Options
Downloads
Patches
Plain Diff
chore(koolbox): Add validation for resources
parent
3814d6c3
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Makefile
+4
-0
4 additions, 0 deletions
Makefile
scripts/validate.sh
+68
-0
68 additions, 0 deletions
scripts/validate.sh
with
72 additions
and
0 deletions
Makefile
+
4
−
0
View file @
4526f7b0
...
@@ -18,6 +18,10 @@ cli: ## Install koolbox CLI (Contains all tools used in this project)
...
@@ -18,6 +18,10 @@ cli: ## Install koolbox CLI (Contains all tools used in this project)
cli-config
:
##
Configure koolbox CLI (To setup terraform values as well was tokens)
cli-config
:
##
Configure koolbox CLI (To setup terraform values as well was tokens)
cd
./cli
&&
make config
cd
./cli
&&
make config
.PHONY
:
validate
validate
:
./scripts/validate.sh
.PHONY
:
deploy
.PHONY
:
deploy
deploy
:
check-machine
##
Deploy infrastructure on Hetzner Cloud
deploy
:
check-machine
##
Deploy infrastructure on Hetzner Cloud
cd
./terraform
&&
make apply
cd
./terraform
&&
make apply
...
...
This diff is collapsed.
Click to expand it.
scripts/validate.sh
0 → 100755
+
68
−
0
View file @
4526f7b0
#!/usr/bin/env bash
# This script downloads the Flux OpenAPI schemas, then it validates the
# Flux custom resources and the kustomize overlays using kubeval.
# This script is meant to be run locally and in CI before the changes
# are merged on the main branch that's synced by Flux.
# Copyright 2020 The Flux authors. All rights reserved.
#
# 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.
# This script is meant to be run locally and in CI to validate the Kubernetes
# manifests (including Flux custom resources) before changes are merged into
# the branch synced by Flux in-cluster.
# Prerequisites
# - yq v4.6
# - kustomize v4.1
# - kubeval v0.15
set
-o
errexit
KUBERNETES_VERSION
=
1.21.8
echo
"INFO - Downloading Flux OpenAPI schemas"
mkdir
-p
/tmp/flux-crd-schemas/master-standalone-strict
curl
-sL
https://github.com/fluxcd/flux2/releases/latest/download/crd-schemas.tar.gz |
tar
zxf -
-C
/tmp/flux-crd-schemas/master-standalone-strict
find
.
-type
f
-name
'*.yaml'
-print0
|
while
IFS
=
read
-r
-d
$'
\0
'
file
;
do
echo
"INFO - Validating
$file
"
yq e
'true'
"
$file
"
>
/dev/null
done
echo
"INFO - Validating clusters"
find ./clusters
-maxdepth
2
-type
f
-name
'*.yaml'
-print0
|
while
IFS
=
read
-r
-d
$'
\0
'
file
;
do
kubeval
${
file
}
--strict
--ignore-missing-schemas
--kubernetes-version
${
KUBERNETES_VERSION
}
--additional-schema-locations
=
file:///tmp/flux-crd-schemas
if
[[
${
PIPESTATUS
[0]
}
!=
0
]]
;
then
exit
1
fi
done
# mirror kustomize-controller build options
kustomize_flags
=
"--load-restrictor=LoadRestrictionsNone --reorder=legacy"
kustomize_config
=
"kustomization.yaml"
echo
"INFO - Validating kustomize overlays"
find
.
-type
f
-name
$kustomize_config
-print0
|
while
IFS
=
read
-r
-d
$'
\0
'
file
;
do
echo
"INFO - Validating kustomization
${
file
/%
$kustomize_config
}
"
kustomize build
"
${
file
/%
$kustomize_config
}
"
$kustomize_flags
|
\
kubeval
--ignore-missing-schemas
--strict
--kubernetes-version
${
KUBERNETES_VERSION
}
--additional-schema-locations
=
file:///tmp/flux-crd-schemas
if
[[
${
PIPESTATUS
[0]
}
!=
0
]]
;
then
exit
1
fi
done
echo
"INFO - Validation complete"
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment