Skip to content

Commit

Permalink
feat: WAIOps Infrastructure Automation
Browse files Browse the repository at this point in the history
  • Loading branch information
nastacio committed Jun 15, 2022
1 parent 2fe8875 commit 8d9aeea
Show file tree
Hide file tree
Showing 15 changed files with 276 additions and 4 deletions.
4 changes: 2 additions & 2 deletions config/argocd-cloudpaks/cp4aiops/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.4.3
version: 0.5.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
appVersion: "0.8.0"
appVersion: "0.8.4"
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ spec:
value: "{{.Values.modules.aimgr}}"
- name: modules.emgr
value: "{{.Values.modules.emgr}}"
- name: modules.ia
value: "{{.Values.modules.ia}}"
- name: repoURL
value: ${ARGOCD_APP_SOURCE_REPO_URL}
- name: serviceaccount.argocd_application_controller
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{{- $ia := .Values.modules.ia }}
{{- if eq ( default false $ia ) true }}
---
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
creationTimestamp: null
name: cp4aiops-ia
namespace: openshift-gitops
annotations:
argocd.argoproj.io/sync-wave: "130"
spec:
destination:
namespace: {{.Values.metadata.argocd_app_namespace}}
server: https://kubernetes.default.svc
ignoreDifferences:
- group: argoproj.io
jsonPointers:
- /spec/source/repoURL
- /spec/source/targetRevision
- /status
kind: Application
- group: v1
jsonPointers:
- /metadata/labels
kind: Namespace
project: default
source:
helm:
parameters:
- name: argocd_app_name
value: ${ARGOCD_APP_NAME}
- name: argocd_app_namespace
value: ${ARGOCD_APP_NAMESPACE}
- name: metadata.argocd_app_namespace
value: {{.Values.metadata.argocd_app_namespace}}
- name: repoURL
value: ${ARGOCD_APP_SOURCE_REPO_URL}
- name: serviceaccount.argocd_application_controller
value: {{.Values.serviceaccount.argocd_application_controller}}
- name: storageclass.rwx
value: {{.Values.storageclass.rwx}}
- name: targetRevision
value: ${ARGOCD_APP_SOURCE_TARGET_REVISION}
path: config/cloudpaks/cp4aiops/install-ia
repoURL: {{.Values.repoURL}}
targetRevision: {{.Values.targetRevision}}
syncPolicy:
automated:
prune: true
selfHeal: true
status:
health: {}
summary: {}
sync:
comparedTo:
destination: {}
source:
repoURL: ""
status: ""
{{- end }}
1 change: 1 addition & 0 deletions config/argocd-cloudpaks/cp4aiops/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ storageclass:
modules:
aimgr: true
emgr: true
ia: false
21 changes: 21 additions & 0 deletions config/argocd/templates/0200-argocd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,27 @@ spec:
hs.status = "Progressing"
hs.message = "Unknown"
return hs
aiops.ibm.com/IAConfig:
health.lua: |
hs = {}
if obj.status ~= nil then
if obj.status.phase ~= nil then
hs.message = obj.status.phase
if obj.status.phase == "Running" then
hs.status = "Healthy"
elseif obj.status.phase == "Failed" then
hs.status = "Degraded"
hs.message = obj.status.failureMessage
else
hs.status = "Progressing"
end
return hs
end
end
hs.status = "Progressing"
hs.message = "Unknown"
return hs
noi.ibm.com/NOI:
health.lua: |
hs = {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ spec:
automation_base_instance_name="$(oc get AutomationBase.base.automation.ibm.com \
--namespace "${TARGET_NAMESPACE}" \
-o jsonpath='{.items[].metadata.name}' \
--ignore-not-found=false)" \
--ignore-not-found=true)" \
|| result=1
fi
Expand All @@ -50,7 +50,7 @@ spec:
echo "INFO: Did not find an existing instance of AutomationBase in the namespace."
else
echo "INFO: Found an existing instance of AutomationBase in the namespace."
abase_params=$(oc get AutomationBase.base.automation.ibm.com "${automation_base_instance_name}" --namespace ${TARGET_NAMESPACE} -o jsonpath='{.spec}' --ignore-not-found=false) \
abase_params=$(oc get AutomationBase.base.automation.ibm.com "${automation_base_instance_name}" --namespace ${TARGET_NAMESPACE} -o jsonpath='{.spec}' --ignore-not-found=true) \
|| result=1
if [[ ! ${abase_params} == *aiops* ]]; then
Expand Down
21 changes: 21 additions & 0 deletions config/cloudpaks/cp4aiops/install-ia/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*~
# Various IDEs
.project
.idea/
*.tmproj
24 changes: 24 additions & 0 deletions config/cloudpaks/cp4aiops/install-ia/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
apiVersion: v2
name: icp4aiops-ia
description: Cloud Pak for Watson AIOps - Infrastructure Automation

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.8.5

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
appVersion: "3.3.2"
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
---
apiVersion: batch/v1
kind: Job
metadata:
annotations:
argocd.argoproj.io/hook: PreSync
name: pre-cp4aiops-ia-adjust-parameters
namespace: openshift-gitops
spec:
template:
spec:
containers:
- name: config
image: quay.io/openshift/origin-cli:latest
imagePullPolicy: IfNotPresent
env:
- name: ARGOCD_NAMESPACE
value: {{.Values.metadata.argocd_namespace}}
command:
- /bin/sh
- -c
- |
set -eo pipefail
set -x
storage_class_rwx="$(oc get configmap argocd-cp4aiops-config \
--namespace "${ARGOCD_NAMESPACE}" -o jsonpath='{.data.storageclass\.rwx}')"
if [ -z "${storage_class_rwx}" ] ; then
echo "ERROR: Did not find storage classes for target platform."
exit 1
fi
echo "INFO: Install Argo CLI."
# Install it from cluster, not from Internet, so airgap scenarios still work
argo_route=openshift-gitops-server
argo_secret=openshift-gitops-cluster
export HOME=/tmp
argo_cmd="${HOME}/argocd"
result=0
argo_url=$(oc get route ${argo_route} -n ${ARGOCD_NAMESPACE} -ojsonpath='{.spec.host}') \
&& curl -skL "${argo_url}/download/argocd-linux-amd64" -o "${argo_cmd}" \
&& chmod 755 "${argo_cmd}" \
&& argo_pwd=$(oc get secret ${argo_secret} -n ${ARGOCD_NAMESPACE} -ojsonpath='{.data.admin\.password}' | base64 -d ; echo ) \
&& "${argo_cmd}" login "${argo_url}" --username admin --password "${argo_pwd}" --insecure \
|| result=1
app_name=cp4aiops-ia
if [ ${result} -eq 0 ]; then
echo "INFO: Patching storage for ${app_name}." \
&& "${argo_cmd}" app set "${app_name}" \
--helm-set-string storageclass.rwx="${storage_class_rwx}" \
&& echo "INFO: ${app_name} successfully updated storage classes." \
|| result=1
fi
echo "INFO: Application ${app_name} current parameters:"
"${argo_cmd}" app get "${app_name}" --show-params
exit ${result}
restartPolicy: Never
serviceAccountName: {{.Values.serviceaccount.ibm_cloudpaks_installer}}
backoffLimit: 2
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
apiVersion: aiops.ibm.com/v1alpha1
kind: IAConfig
metadata:
annotations:
argocd.argoproj.io/sync-options: SkipDryRunOnMissingResource=true
argocd.argoproj.io/sync-wave: "200"
name: ibm-ia-installer
namespace: "{{.Values.metadata.argocd_app_namespace}}"
spec:
imagePullSecret: ibm-entitlement-key
infraAutoComposableComponents:
- enabled: true
name: ibm-management-im-install
spec: {}
- enabled: true
name: ibm-management-cam-install
spec: {}
license:
accept: true
storageClass: {{.Values.storageclass.rwx}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
annotations:
argocd.argoproj.io/sync-wave: "21"
creationTimestamp: null
name: argocd-cp4aiops-ia-role
namespace: "{{.Values.metadata.argocd_app_namespace}}"
rules:
- apiGroups: ["aiops.ibm.com"]
resources: ["iaconfigs"]
verbs: ["get", "create", "update", "patch", "delete"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
annotations:
argocd.argoproj.io/sync-wave: "21"
creationTimestamp: null
name: argocd-cp4aiops-ia-binding
namespace: "{{.Values.metadata.argocd_app_namespace}}"
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: argocd-cp4aiops-ia-role
subjects:
- kind: ServiceAccount
name: "{{.Values.serviceaccount.argocd_application_controller}}"
namespace: "{{.Values.metadata.argocd_namespace}}"
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
annotations:
argocd.argoproj.io/sync-wave: "100"
name: ibm-infrastructure-automation-operator
namespace: "{{.Values.metadata.argocd_app_namespace}}"
spec:
channel: v3.3
installPlanApproval: Automatic
name: ibm-infrastructure-automation-operator
source: ibm-operator-catalog
sourceNamespace: openshift-marketplace
10 changes: 10 additions & 0 deletions config/cloudpaks/cp4aiops/install-ia/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
serviceaccount:
argocd_application_controller: openshift-gitops-argocd-application-controller
ibm_cloudpaks_installer: ibm-cloudpaks-installer
metadata:
argocd_app_namespace: ibm-cloudpaks
argocd_namespace: openshift-gitops
post_install_wait: 2h
storageclass:
rwx: ocs-storagecluster-cephfs
1 change: 1 addition & 0 deletions tests/prebuild/yamllint-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ ignore: |
config/argocd-cloudpaks/cp4aiops/templates/021-cloudpaks-emgr-binding.yaml
config/argocd-cloudpaks/cp4aiops/templates/110-cp4aiops-aimgr-app.yaml
config/argocd-cloudpaks/cp4aiops/templates/120-cp4aiops-emgr-app.yaml
config/argocd-cloudpaks/cp4aiops/templates/130-cp4aiops-ia-app.yaml
config/argocd-cloudpaks/cp4d/templates/cp4d-module-template-app.yaml
config/argocd-cloudpaks/cp4i/templates/0300-cp4i-module-template-app.yaml
config/argocd-cloudpaks/cp4i/templates/0400-cp4i-client-app.yaml
Expand Down

0 comments on commit 8d9aeea

Please sign in to comment.