Skip to content

Ingress and other schema update corrections #46

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
sudo mv kubeconform /usr/local/bin
- name: check all yaml
run: |
comm -3 <(find . | grep yaml$ | sort) <(cat .kubeconform-ignore | sort) | xargs -n1 kubeconform --strict | tee -a apply.txt
./bin/test.sh | tee -a apply.txt
- name: upload artifact
uses: actions/upload-artifact@v2
with:
Expand Down
16 changes: 11 additions & 5 deletions Ingress/fanout.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
apiVersion: networking.k8s.io/v1beta1
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: ingress-fanout
Expand All @@ -12,9 +12,15 @@ spec:
paths:
- path: /path1
backend:
serviceName: testsvc1
servicePort: 4201
service:
name: testsvc1
port:
number: 4201
pathType: exact
- path: /path2
backend:
serviceName: testsvc2
servicePort: 4202
service:
name: testsvc2
port:
number: 4202
pathType: exact
2 changes: 1 addition & 1 deletion Ingress/ingress-class.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
apiVersion: networking.k8s.io/v1beta1
apiVersion: networking.k8s.io/v1
kind: IngressClass
metadata:
name: external-lb
Expand Down
10 changes: 6 additions & 4 deletions Ingress/ingress.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
---
apiVersion: networking.k8s.io/v1beta1
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: test-ingress
spec:
backend:
serviceName: testsvc
servicePort: 80
defaultBackend:
service:
name: testsvc
port:
number: 80
23 changes: 16 additions & 7 deletions Ingress/nohost.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
apiVersion: networking.k8s.io/v1beta1
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: name-virtual-host-ingress
Expand All @@ -9,17 +9,26 @@ spec:
http:
paths:
- backend:
serviceName: testsvc1
servicePort: 80
service:
name: testsvc1
port:
number: 80
pathType: exact
- host: second.foo.com
http:
paths:
- backend:
serviceName: testsvc2
servicePort: 80
service:
name: testsvc2
port:
number: 80
pathType: exact
# No host supplied here
- http:
paths:
- backend:
serviceName: testsvc3
servicePort: 80
service:
name: testsvc3
port:
number: 80
pathType: exact
8 changes: 5 additions & 3 deletions Ingress/rewrite.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
apiVersion: networking.k8s.io/v1beta1
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: ingress-rewrite
Expand All @@ -12,5 +12,7 @@ spec:
- path: /rewritepath
pathType: Prefix
backend:
serviceName: testsvc
servicePort: 80
service:
name: testsvc
port:
number: 80
9 changes: 6 additions & 3 deletions Ingress/tls.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ data:
tls.key: YQo=
type: kubernetes.io/tls
---
apiVersion: networking.k8s.io/v1beta1
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: ingress-tls
Expand All @@ -24,5 +24,8 @@ spec:
paths:
- path: /
backend:
serviceName: testsvc1
servicePort: 80
service:
name: testsvc1
port:
number: 80
pathType: exact
16 changes: 11 additions & 5 deletions Ingress/virtualhosting.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
apiVersion: networking.k8s.io/v1beta1
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: name-virtual-host-ingress
Expand All @@ -9,11 +9,17 @@ spec:
http:
paths:
- backend:
serviceName: testsvc1
servicePort: 80
service:
name: testsvc1
port:
number: 80
pathType: exact
- host: bar.foo.com
http:
paths:
- backend:
serviceName: testsvc2
servicePort: 80
service:
name: testsvc2
port:
number: 80
pathType: exact
8 changes: 5 additions & 3 deletions PodSecurityPolicy/Ingress/simple.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Requires an appropriate ingress controller to exist on the cluster for this to take effect
---
apiVersion: networking.k8s.io/v1beta1
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: simple
Expand All @@ -13,5 +13,7 @@ spec:
- path: /testpath
pathType: Prefix
backend:
serviceName: test
servicePort: 80
service:
name: test
port:
number: 80
2 changes: 1 addition & 1 deletion Service/Pod.spec.subdomain/subdomain.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# DNS serves an A or AAAA record at that name, pointing to the Pod's IP.
# Both pods "subdomain-simple-pod-1" and "subdomain-simple-pod-2" can have their distinct A or AAAA records.

Example:
---
apiVersion: v1
kind: Service
metadata:
Expand Down
19 changes: 0 additions & 19 deletions Service/spec.topologyKeys/fallback.yaml

This file was deleted.

102 changes: 102 additions & 0 deletions bin/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
#!/usr/bin/env bash

# From: https://betterdev.blog/minimal-safe-bash-script-template/

set -Eeuo pipefail
trap cleanup SIGINT SIGTERM ERR EXIT

script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
abs_script_dir=$(readlink -f ${script_dir})
elif [[ "$OSTYPE" == "darwin"* ]]; then
abs_script_dir=$(greadlink -f ${script_dir})
elif [[ "$OSTYPE" == "cygwin" ]]; then
abs_script_dir=$(readlink -f ${script_dir})
elif [[ "$OSTYPE" == "msys" ]]; then
abs_script_dir=$(readlink -f ${script_dir})
elif [[ "$OSTYPE" == "win32" ]]; then
abs_script_dir=$(readlink -f ${script_dir})
elif [[ "$OSTYPE" == "freebsd"* ]]; then
abs_script_dir=$(readlink -f ${script_dir})
else
abs_script_dir=$(readlink -f ${script_dir})
fi

usage() {
cat << EOF # remove the space between << and EOF, this is due to web plugin issue
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [ --version <k8s_version>] arg1 [arg2...]

Script description here.

Available options:

-h, --help Print this help and exit
-v, --verbose Print script debug info
--version Kubernetes version, default 'master'
EOF
exit
}

cleanup() {
trap - SIGINT SIGTERM ERR EXIT
# script cleanup here
}

setup_colors() {
if [[ -t 2 ]] && [[ -z "${NO_COLOR-}" ]] && [[ "${TERM-}" != "dumb" ]]; then
NOFORMAT='\033[0m' RED='\033[0;31m' GREEN='\033[0;32m' ORANGE='\033[0;33m' BLUE='\033[0;34m' PURPLE='\033[0;35m' CYAN='\033[0;36m' YELLOW='\033[1;33m'
else
NOFORMAT='' RED='' GREEN='' ORANGE='' BLUE='' PURPLE='' CYAN='' YELLOW=''
fi
}

msg() {
echo >&2 -e "${1-}"
}

die() {
local msg=$1
local code=${2-1} # default exit status 1
msg "$msg"
exit "$code"
}

parse_params() {
# default values of variables set from params
flag=0
k8s_version=master

while :; do
case "${1-}" in
-h | --help) usage ;;
-v | --verbose) set -x ;;
--no-color) NO_COLOR=1 ;;
-f | --flag) flag=1 ;; # example flag
--version)
k8s_versionm="${2-}"
shift
;;
-?*) die "Unknown option: $1" ;;
*) break ;;
esac
shift
done

#args=("$@")

# check required params and arguments
[[ -z "${k8s_version-}" ]] && die "Missing required parameter: k8s_version"
#[[ ${#args[@]} -eq 0 ]] && die "Missing script arguments"

return 0
}

parse_params "$@"
setup_colors

# script logic here

(
cd ${abs_script_dir}/.. || exit 1
comm -3 <(find . | grep yaml$ | sort) <(cat .kubeconform-ignore | sort) | xargs -n1 kubeconform --strict -kubernetes-version $k8s_version
)