forked from kiali/kiali-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support for OSSMC in the Kiali Operator (kiali#691)
* support for OSSMC in the Kiali Operator * add ossmc support to 1.76 olm metadata
- Loading branch information
1 parent
a91c1bd
commit 2abdd08
Showing
62 changed files
with
1,972 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,182 @@ | ||
#!/bin/bash | ||
|
||
############################################################################## | ||
# validate-ossmconsole-cr.sh | ||
# | ||
# This script can be used to validate an OSSMConsole CR. | ||
# | ||
# To use this script, you must: | ||
# * Have "oc" or "kubectl" | ||
# * Be connected to a cluster | ||
# * Have cluster-admin rights | ||
# | ||
############################################################################## | ||
|
||
set -u | ||
|
||
crd() { | ||
local crd_file="" | ||
|
||
# if not specified, use the default location; otherwise, it is either a file or a URL | ||
if [ -z "${OSSMCONSOLE_CRD_LOCATION:-}" ]; then | ||
local script_root="$(cd "$(dirname "$0")" ; pwd -P)" | ||
crd_file="${script_root}/../crd/kiali.io_ossmconsoles.yaml" | ||
elif [ -f "${OSSMCONSOLE_CRD_LOCATION}" ]; then | ||
crd_file="${OSSMCONSOLE_CRD_LOCATION}" | ||
fi | ||
([ -n "${crd_file}" ] && cat "${crd_file}" || curl -sL "${OSSMCONSOLE_CRD_LOCATION}") | sed 's/ name: ossmconsoles.kiali.io/ name: testossmconsoles.kiali.io/g' | sed 's/ kind: OSSMConsole/ kind: TestOSSMConsole/g' | sed 's/ listKind: OSSMConsoleList/ listKind: TestOSSMConsoleList/g' | sed 's/ plural: ossmconsoles/ plural: testossmconsoles/g' | sed 's/ singular: ossmconsole/ singular: testossmconsole/g' | ||
} | ||
|
||
# process command line args to override environment | ||
_CMD="" | ||
while [[ $# -gt 0 ]]; do | ||
key="$1" | ||
case $key in | ||
-ce|--client-exe) CLIENT_EXE="$2" ; shift;shift ;; | ||
-crd|--crd-location) OSSMCONSOLE_CRD_LOCATION="$2" ; shift;shift ;; | ||
-cf|--cr-file) OSSMCONSOLE_CR_FILE="$2" ; shift;shift ;; | ||
-cn|--cr-name) OSSMCONSOLE_CR_NAME="$2" ; shift;shift ;; | ||
-n|--namespace) NAMESPACE="$2" ; shift;shift ;; | ||
-pc|--print-crd) PRINT_CRD="$2" ; shift;shift ;; | ||
-h|--help) | ||
cat <<HELPMSG | ||
$0 [option...] | ||
-ce|--client-exe | ||
The path to the client executable. Should be a path to either a "oc" or "kubectl" executable. | ||
-crd|--crd-location | ||
The file or URL location where the OSSMConsole CRD is. This CRD must include the schema. | ||
If not specified, the internally defined CRD is used. | ||
-cf|--cr-file | ||
The file of the OSSMConsole CR to test. | ||
-cn|--cr-name | ||
The name of an existing OSSMConsole CR to test. | ||
-n|--namespace | ||
The namespace where the existing CR is or where the test CR will be created. | ||
Default: "default" | ||
-pc|--print-crd | ||
If true, then this script will just print the CRD used to validate. It will not validate anything. | ||
Default "false" | ||
HELPMSG | ||
exit 1 | ||
;; | ||
*) | ||
echo "Unknown argument [$key]. Aborting." | ||
exit 1 | ||
;; | ||
esac | ||
done | ||
|
||
# Set up some defaults | ||
|
||
: ${NAMESPACE:=default} | ||
: ${PRINT_CRD:=false} | ||
|
||
# If we are to print the CRD, do it now immediately and then exit. Nothing else to do. | ||
if [ "${PRINT_CRD}" == "true" ]; then | ||
echo "$(crd)" | ||
exit $? | ||
fi | ||
|
||
echo "=== SETTINGS ===" | ||
echo OSSMCONSOLE_CRD_LOCATION=${OSSMCONSOLE_CRD_LOCATION:-} | ||
echo OSSMCONSOLE_CR_FILE=${OSSMCONSOLE_CR_FILE:-} | ||
echo OSSMCONSOLE_CR_NAME=${OSSMCONSOLE_CR_NAME:-} | ||
echo NAMESPACE=${NAMESPACE} | ||
echo PRINT_CRD=${PRINT_CRD} | ||
echo "=== SETTINGS ===" | ||
|
||
# Determine what cluster client tool we are using. | ||
if [ -z "${CLIENT_EXE:-}" ]; then | ||
if which oc &>/dev/null; then | ||
CLIENT_EXE="$(which oc)" | ||
echo "Using 'oc' located here: ${CLIENT_EXE}" | ||
else | ||
if which kubectl &>/dev/null; then | ||
CLIENT_EXE="$(which kubectl)" | ||
echo "Using 'kubectl' located here: ${CLIENT_EXE}" | ||
else | ||
echo "ERROR! You do not have 'oc' or 'kubectl' in your PATH. Please install it and retry." | ||
exit 1 | ||
fi | ||
fi | ||
else | ||
echo "Client executable: ${CLIENT_EXE}" | ||
fi | ||
|
||
if [ -z "${OSSMCONSOLE_CR_FILE:-}" -a -z "${OSSMCONSOLE_CR_NAME:-}" ]; then | ||
echo "ERROR! You must specify one of either --cr-file or --cr-name" | ||
exit 1 | ||
fi | ||
|
||
if [ -n "${OSSMCONSOLE_CR_FILE:-}" -a -n "${OSSMCONSOLE_CR_NAME:-}" ]; then | ||
echo "ERROR! You must specify only one of either --cr-file or --cr-name" | ||
exit 1 | ||
fi | ||
|
||
if [ -n "${OSSMCONSOLE_CR_FILE:-}" -a ! -f "${OSSMCONSOLE_CR_FILE:-}" ]; then | ||
echo "ERROR! OSSMConsole CR file is not found: [${OSSMCONSOLE_CR_FILE:-}]" | ||
exit 1 | ||
fi | ||
|
||
if [ -n "${OSSMCONSOLE_CR_NAME:-}" ]; then | ||
if ! ${CLIENT_EXE} get -n "${NAMESPACE}" ossmconsole "${OSSMCONSOLE_CR_NAME}" &> /dev/null; then | ||
echo "ERROR! OSSMConsole CR [${OSSMCONSOLE_CR_NAME}] does not exist in namespace [${NAMESPACE}]" | ||
exit 1 | ||
fi | ||
fi | ||
|
||
# Make sure we have admin rights to some cluster | ||
if ! ${CLIENT_EXE} get namespaces &> /dev/null ; then | ||
echo "ERROR! You must be connected to/logged into a cluster" | ||
exit 1 | ||
fi | ||
if [ "$(${CLIENT_EXE} auth can-i create crd --all-namespaces)" != "yes" ]; then | ||
echo "ERROR! You must have cluster-admin permissions" | ||
exit 1 | ||
fi | ||
|
||
# install the test CRD with the schema | ||
if ! echo "$(crd)" | ${CLIENT_EXE} apply --validate=true --wait=true -f - &> /dev/null ; then | ||
echo "ERROR! Failed to install the test CRD" | ||
exit 1 | ||
fi | ||
|
||
# wait for the test CRD to be established and then give k8s a few more seconds. | ||
# if we don't do this, the validation test may report a false negative. | ||
if ! ${CLIENT_EXE} wait --for condition=established --timeout=60s crd/testossmconsoles.kiali.io &> /dev/null ; then | ||
echo "WARNING! Test CRD is not established yet. The validation test may not produce accurate results." | ||
else | ||
for s in 3 2 1; do echo -n "." ; sleep 1 ; done | ||
echo | ||
fi | ||
|
||
# validate the CR by creating a test version of it | ||
echo "Validating the CR:" | ||
echo "----------" | ||
if [ -n "${OSSMCONSOLE_CR_FILE:-}" ]; then | ||
if ! cat "${OSSMCONSOLE_CR_FILE}" | sed 's/kind: OSSMConsole/kind: TestOSSMConsole/g' | sed 's/- kiali.io\/finalizer//g' | kubectl apply -n ${NAMESPACE} -f - ; then | ||
echo "----------" | ||
echo "ERROR! Validation failed for OSSMConsole CR [${OSSMCONSOLE_CR_FILE}]" | ||
exit 1 | ||
else | ||
echo "----------" | ||
echo "OSSMConsole CR [${OSSMCONSOLE_CR_FILE}] is valid." | ||
fi | ||
else | ||
if ! ${CLIENT_EXE} get -n "${NAMESPACE}" ossmconsole "${OSSMCONSOLE_CR_NAME}" -o yaml | sed 's/kind: OSSMConsole/kind: TestOSSMConsole/g' | sed 's/- kiali.io\/finalizer//g' | kubectl apply -n "${NAMESPACE}" -f - ; then | ||
echo "----------" | ||
echo "ERROR! Validation failed for OSSMConsole CR [${OSSMCONSOLE_CR_NAME}] in namespace [${NAMESPACE}]" | ||
exit 1 | ||
else | ||
echo "----------" | ||
echo "OSSMConsole CR [${OSSMCONSOLE_CR_NAME}] in namespace [${NAMESPACE}] is valid." | ||
fi | ||
fi | ||
|
||
# delete the test CRD (which deletes the test CR along with it) | ||
if ! echo "$(crd)" | ${CLIENT_EXE} delete --wait=true -f - &> /dev/null ; then | ||
echo "ERROR! Failed to delete the test CRD. You should remove it manually." | ||
exit 1 | ||
fi |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
template_path: ./apigen-crd.template | ||
|
||
source_repositories: | ||
- url: https://github.com/kiali/kiali-operator | ||
organization: kiali | ||
short_name: kiali-operator | ||
commit_reference: master | ||
crd_paths: | ||
- crd-docs/crd | ||
cr_paths: | ||
- crd-docs/cr | ||
metadata: | ||
ossmconsoles.kiali.io: | ||
owner: | ||
- https://github.com/orgs/kiali/teams/maintainers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
--- | ||
title: {{ .Title }} CR Reference | ||
linkTitle: {{ .Title }} CR Reference | ||
description: | | ||
{{- if .Description }} | ||
{{ .Description | indent 2 }} | ||
{{- else }} | ||
Reference page for the {{ .Title }} CR. | ||
The Kiali Operator will watch for a resource of this type and install the OSSM Console plugin according to that resource's configuration. Only one resource of this type should exist at any one time. | ||
{{- end }} | ||
technical_name: {{ .NamePlural }}.{{ .Group }} | ||
source_repository: {{ .SourceRepository }} | ||
source_repository_ref: {{ .SourceRepositoryRef }} | ||
--- | ||
|
||
{{ if .VersionSchemas }} | ||
{{ range $versionName, $versionSchema := .VersionSchemas }} | ||
<div class="crd-schema-version"> | ||
|
||
{{with .ExampleCR}} | ||
<h3 id="example-cr">Example CR</h3> | ||
<em>(all values shown here are the defaults unless otherwise noted)</em> | ||
|
||
```yaml | ||
{{ .|raw -}} | ||
``` | ||
{{end}} | ||
|
||
### Validating your OSSMConsole CR | ||
|
||
A tool is available to allow you to check your own OSSMConsole CR to ensure it is valid. Simply download [the validation script](https://raw.githubusercontent.com/kiali/kiali-operator/master/crd-docs/bin/validate-ossmconsole-cr.sh) and run it, passing in the location of the OSSMConsole CRD you wish to validate with (e.g. the latest version is found [here](https://raw.githubusercontent.com/kiali/kiali-operator/master/crd-docs/crd/kiali.io_ossmconsoles.yaml)) and the location of your OSSMConsole CR. You must be connected to/logged into a cluster for this validation tool to work. | ||
|
||
For example, to validate an OSSMConsole CR named `ossmconsole` in the namespace `istio-system` using the latest version of the OSSMConsole CRD, run the following: | ||
<pre> | ||
bash <(curl -sL https://raw.githubusercontent.com/kiali/kiali-operator/master/crd-docs/bin/validate-ossmconsole-cr.sh) \ | ||
-crd https://raw.githubusercontent.com/kiali/kiali-operator/master/crd-docs/crd/kiali.io_ossmconsoles.yaml \ | ||
--cr-name ossmconsole \ | ||
-n istio-system | ||
</pre> | ||
|
||
For additional help in using this validation tool, pass it the `--help` option. | ||
|
||
<h3 id="property-details">Properties</h3> | ||
|
||
{{ range $versionSchema.Properties }} | ||
<div class="property depth-{{.Depth}}"> | ||
<div class="property-header"> | ||
<hr/> | ||
<h3 class="property-path" id="{{.Path}}">{{.Path}}</h3> | ||
</div> | ||
<div class="property-body"> | ||
<div class="property-meta"> | ||
{{with .Type}}<span class="property-type">({{.}})</span>{{end}} | ||
{{ if not .Required }} | ||
{{ else -}} | ||
<span class="property-required">*Required*</span> | ||
{{ end -}} | ||
</div> | ||
{{with .Description}} | ||
<div class="property-description"> | ||
{{.|markdown}} | ||
</div> | ||
{{end}} | ||
</div> | ||
</div> | ||
{{ end }} | ||
|
||
|
||
{{ if .Annotations }} | ||
<h3 id="annotation-details">Annotations</h3> | ||
|
||
{{ range $versionSchema.Annotations }} | ||
<div class="annotation"> | ||
<div class="annotation-header"> | ||
<h3 class="annotation-path" id="{{.CRDVersion}}-{{.Annotation}}">{{.Annotation}}</h3> | ||
</div> | ||
<div class="annotation-body"> | ||
<div class="annotation-meta"> | ||
{{with .Release}}<span class="annotation-release">{{.}}</span>{{end}} | ||
</div> | ||
{{with .Documentation}} | ||
<div class="annotation-description"> | ||
{{.|markdown}} | ||
</div> | ||
{{end}} | ||
</div> | ||
</div> | ||
{{ end }} | ||
{{ end }} | ||
|
||
</div> | ||
{{end}} | ||
|
||
{{ else }} | ||
<div class="crd-noversions"> | ||
<p>We currently cannot show any schema information on this <abbr title="custom resource definition">CRD</abbr>. Sorry for the inconvenience!</p> | ||
<p>Please refer to <a href="https://kiali.io">Kiali Documentation</a>.</p> | ||
</div> | ||
{{ end }} |
Oops, something went wrong.