Skip to content

Commit

Permalink
Merge pull request #22 from OpenShiftDemos/production
Browse files Browse the repository at this point in the history
Move production to main branch
  • Loading branch information
gnunn1 authored Oct 17, 2024
2 parents 10fadf2 + 3233ec9 commit e77e9e0
Show file tree
Hide file tree
Showing 108 changed files with 1,393 additions and 990 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
www/
target/
!.mvn/wrapper/maven-wrapper.jar
audit.log
Expand Down Expand Up @@ -40,4 +41,4 @@ package*
!package.json
node_modules
.firebaserc
.firebase
.firebase
9 changes: 0 additions & 9 deletions Dockerfile

This file was deleted.

875 changes: 674 additions & 201 deletions LICENSE

Large diffs are not rendered by default.

83 changes: 81 additions & 2 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,91 @@ and canary strategies with Rollouts as well as automated testing using Analysis.

#### Installation

Eventually this workshop will be available in RHDP but for now it can be installed as follows:
This workshop is available in the Red Hat Demo Platform (RHDP) for Red Hat employees and partners. It can however be installed manually:

* Provision OpenShift Workshop 4.13 instance in RHDP with the desired number of users
* Provision OpenShift Workshop 4.14 instance in RHDP with the desired number of users
* Login on the command line as the `admin` user with the credentials RHDP provided
* Modify `bootstrap/bootstrap/ansible/bootstrap.yaml` to set the number of users you need, this must match the number of users selected in RHDP
* Run the command `./bootstrap/bootstrap.sh`
Note that the installation is using ansible so you must have ansible installed on your system along with the requirements to use the ansible
k8s module.

#### Developing Workshop

##### Using Containers (Recommended)

In order to test and develop on your local machine, you can use a specially built container with Podman or Docker as follows.

[source,sh]
----
podman run --rm --name antora -v $PWD:/antora -p 8080:8080 -i -t ghcr.io/juliaaano/antora-viewer
----

Live-reload is not supported.

##### Using Local Files (Less Recommended)

. Create a git repo from this template
. Clone the repo and `cd` into it
. Run ./utilities/lab-serve
. Open http://localhost:8080 in your browser
. Run ./utilities/lab-build to build your html

To rebuild your html, run `./utilites/build`.

#### Understanding the Basic Template Directory Structure

[source,sh]
----
./content/modules/ROOT/
├── assets
│ └── images # Images used in your content
│ └── example-image.png
├── examples # You can add downloadable assets here
│ └── example-bash-script.sh # e.g. an example bash script
├── nav.adoc # Navigation for your lab
├── pages # Your content goes here
│ ├── index.adoc # First page of your lab, e.g. overview etc
│ ├── module-01.adoc
│ └── module-02.adoc # Sample lab has 2 modules including index.adoc
└── partials # You can add partials here, reusable content inserted inline into your modules
└── example_partial.adoc
----

#### Adding Additional Links

You can add links to external content in the convenient "Links" drop-down on the upper-right of the Showroom Summit 2024 UI.

../content/antora.yml
[source,yaml]
----
asciidoc:
attributes:
page-links:
- url: https://redhat.com
text: Red Hat
- url: https://www.redhat.com/en/summit
text: Summit
----

image::ui-links.png[]

#### Dev Mode

As a convenience to developers, the Dev Mode Extention (disabled by default) displays the asciidoc attributes you have to work with while writing your lab instructions.

. Disable/Enable Dev Mode by changing `enabled: true` or `enabled: false`
+
.default-site.yml
[source,yaml]
----
extensions:
- id: dev-mode
require: ./content/lib/dev-mode.js
enabled: false
----

. Produces
+
image::dev-mode.png[]
7 changes: 4 additions & 3 deletions bootstrap/ansible/bootstrap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

vars:
users: 10
gitops_revision: development
gitops_deployments:
- cluster
- kam
Expand Down Expand Up @@ -94,10 +95,10 @@
- name: Deploy infra applications
kubernetes.core.k8s:
state: present
src: "{{ item }}"
definition: "{{ lookup('template', item) }}"
with_items:
- files/applications/pipelines-operator.yaml
- files/applications/web-terminal-operator.yaml
- pipelines-operator.yaml.j2
- rollouts-manager.yaml.j2

# Todo: Check health of apps
- name: Wait 30 seconds for deployment
Expand Down
2 changes: 1 addition & 1 deletion bootstrap/ansible/files/gitops-operator/subscription.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ metadata:
name: openshift-gitops-operator
namespace: openshift-gitops-operator
spec:
channel: gitops-1.11
channel: gitops-1.13
installPlanApproval: Automatic
name: openshift-gitops-operator
source: redhat-operators
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ spec:
maxDuration: 3m
source:
repoURL: https://github.com/OpenShiftDemos/argo-rollouts-workshop
targetRevision: main
targetRevision: "{{ gitops_revision }}"
path: bootstrap/infra/pipelines-operator/base
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: web-terminal
name: rollouts-manager
namespace: openshift-gitops
spec:
destination:
namespace: openshift-operators
namespace: openshift-gitops
server: 'https://kubernetes.default.svc'
project: default
syncPolicy:
Expand All @@ -21,5 +21,5 @@ spec:
maxDuration: 3m
source:
repoURL: https://github.com/OpenShiftDemos/argo-rollouts-workshop
targetRevision: main
path: bootstrap/infra/web-terminal-operator/base
targetRevision: "{{ gitops_revision }}"
path: bootstrap/infra/rollouts-manager/base
2 changes: 1 addition & 1 deletion bootstrap/ansible/templates/user-appset.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ spec:
selfHeal: false
source:
repoURL: https://github.com/OpenShiftDemos/argo-rollouts-workshop
targetRevision: main
targetRevision: "{{ gitops_revision }}"
path: bootstrap/user
helm:
values: |
Expand Down
2 changes: 2 additions & 0 deletions bootstrap/infra/rollouts-manager/base/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
resources:
- rolloutmanager.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: argoproj.io/v1alpha1
kind: RolloutManager
metadata:
name: argo-rollout
namespace: user{{ .Values.user }}-prod
name: cluster
namespace: openshift-gitops
spec: {}
23 changes: 23 additions & 0 deletions content/antora.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: argo-rollouts-workshop
title: Argo Rollouts Workshop
version: main
nav:
- modules/ROOT/nav.adoc

start_page: ROOT:index.adoc

asciidoc:
attributes:
page-pagination: true
page-links:
- url: https://redhat.com
text: Red Hat
- url: https://docs.openshift.com/gitops
text: OpenShift GitOps
- url: https://argoproj.github.io/rollouts
text: Argo Rollouts
console_url: URL_PLACEHOLDER
login_command: LOGIN_COMMAND_PLACEHOLDER
openshift_cluster_ingress_domain: OPENSHIFT_CLUSTER_INGRESS_DOMAIN_PLACEHOLDER
password: PASSWORD_PLACEHOLDER
user: USER_PLACEHOLDER
85 changes: 85 additions & 0 deletions content/lib/dev-mode.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
'use strict'

module.exports.register = function ({ config }) {
this.once('contentClassified', ({ playbook, contentCatalog }) => {
var pageDetails = {}
console.log('site-wide attributes (as defined in playbook)')
console.log(playbook.asciidoc.attributes)
let fileContents = "== Site Wide Attributes\n\n"
fileContents += `${playbook.asciidoc.attributes || {}}\n`
contentCatalog.getComponents().forEach((component) => {
component.versions.forEach((componentVersion) => {
getUniqueOrigins(contentCatalog, componentVersion).forEach((origin) => {
console.log(`${componentVersion.version}@${componentVersion.name} attributes (as defined in antora.yml)`)
pageDetails = { version: `${componentVersion.version}`, name: `${componentVersion.name}` }
console.log(origin.descriptor.asciidoc?.attributes || {})
fileContents += `== Component Wide Attributes\n\n`
fileContents += `Antora component version@name: \`${componentVersion.version}@${componentVersion.name}\`\n\n`
fileContents += `[source,json]\n----\n`
fileContents += JSON.stringify(origin.descriptor.asciidoc?.attributes || {}, null, 2)
fileContents += `\n----\n`
})
})
})
const newPage = contentCatalog.addFile({
contents: Buffer.from('= Attributes Page\n\nTo disable Dev Mode (this page) comment out the dev-mode.js extenion in the playbook (usually default-site.yml)\n\n' + fileContents),
path: 'modules/ROOT/pages/attrs-page.adoc',
src: {
path: 'modules/ROOT/pages/attrs-page.adoc',
component: pageDetails.name,
version: pageDetails.version,
// component: pageDetails.name || 'modules',
// version: pageDetails.version || 'master',
module: 'ROOT',
family: 'page',
relative: 'attrs-page.adoc',
},
})
})
// add new page to navigation
this.on('navigationBuilt', ({ contentCatalog }) => {
const { addToNavigation = true, devPagesHeading = 'Dev Mode' } = config
const logger = this.getLogger('dev-pages-extension')
contentCatalog.getComponents().forEach(({ versions }) => {
versions.forEach(({ name: component, version, navigation: nav, url: defaultUrl }) => {
const navEntriesByUrl = getNavEntriesByUrl(nav)
const unlistedPages = contentCatalog
.findBy({ component, version, family: 'page' })
.filter((page) => page.out)
.reduce((collector, page) => {
if ((page.pub.url in navEntriesByUrl) || page.pub.url === defaultUrl) return collector
// logger.warn({ file: page.src, source: page.src.origin }, 'detected unlisted dev page')
return collector.concat(page)
}, [])
if (unlistedPages.length && addToNavigation) {
nav.push({
content: devPagesHeading,
items: unlistedPages.map((page) => {
// logger.warn({ content: page, url: page.pub.url }, 'unlisted dev page details')
const navtitle = page.asciidoc.navtitle || page.src.stem
return { content: navtitle, url: page.pub.url, urlType: 'internal' }
}),
root: true,
})
}
})
})
})
}

function getUniqueOrigins (contentCatalog, componentVersion) {
return contentCatalog.findBy({ component: componentVersion.name, version: componentVersion.version })
.reduce((origins, file) => {
const origin = file.src.origin
if (origin && !origins.includes(origin)) origins.push(origin)
return origins
}, [])
}

function getNavEntriesByUrl (items = [], accum = {}) {
items.forEach((item) => {
if (item.urlType === 'internal') accum[item.url.split('#')[0]] = item
getNavEntriesByUrl(item.items, accum)
})
return accum
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ spec:
- name: route-name
value: preview
- name: route-url
value: preview-user%USER%-prod.%SUB_DOMAIN%
value: preview-%USER%-prod.%SUB_DOMAIN%
templates:
- templateName: smoke-tests
template:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ spec:
canary:
canaryService: canary
stableService: stable
trafficRouting:
plugins:
argoproj-labs/openshift:
routes:
- stable
steps:
- setWeight: 20
- analysis:
Expand All @@ -36,7 +41,7 @@ spec:
- name: route-name
value: canary
- name: route-url
value: canary-user%USER%-prod.%SUB_DOMAIN%
value: canary-%USER%-prod.%SUB_DOMAIN%
- pause: {duration: 10s}
- setWeight: 60
- pause: {duration: 10s}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
apiVersion: route.openshift.io/v1
kind: Route
metadata:
annotations:
haproxy.router.openshift.io/disable_cookies: 'true'
haproxy.router.openshift.io/balance: roundrobin
name: stable
spec:
port:
Expand All @@ -25,20 +28,3 @@ spec:
to:
kind: Service
name: canary
---
apiVersion: route.openshift.io/v1
kind: Route
metadata:
name: all
annotations:
haproxy.router.openshift.io/disable_cookies: 'true'
haproxy.router.openshift.io/balance: roundrobin
spec:
port:
targetPort: http
tls:
insecureEdgeTerminationPolicy: Redirect
termination: edge
to:
kind: Service
name: all
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,3 @@ spec:
targetPort: 8080
selector:
app: rollouts-demo
---
apiVersion: v1
kind: Service
metadata:
name: all
spec:
ports:
- name: http
protocol: TCP
port: 8080
targetPort: 8080
selector:
app: rollouts-demo
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ spec:
canary:
canaryService: canary
stableService: stable
trafficRouting:
plugins:
argoproj-labs/openshift:
routes:
- stable
steps:
- setWeight: 20
- pause: {}
Expand Down
Loading

0 comments on commit e77e9e0

Please sign in to comment.