Skip to content
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
49 changes: 28 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ The PagerDuty operator is used to automate integrating Openshift Dedicated clust

This operator runs on [Hive](https://github.com/openshift/hive) and watches for new cluster deployments. Hive is an API driven OpenShift cluster providing OpenShift Dedicated provisioning and management.

## How the PagerDuty Operator works
## How the PagerDuty Opertor works

* The PagerDutyIntegration controller watches for changes to PagerDutyIntegration CRs, and also for changes to appropriately labeled ClusterDeployment CRs (and ConfigMap/Secret/SyncSet resources owned by such a ClusterDeployment).
* For each PagerDutyIntegration CR, it will get a list of matching ClusterDeployments that have the `spec.installed` field set to true and don't have the `api.openshift.com/noalerts` label set.
* For each of these ClusterDeployments, PagerDuty creates a secret which contains the integration key required to communicate with PagerDuty Web application.
* PagerDuty's reconcile function watches for the `installed` field of the `ClusterDeployment` CRD and waits for the cluster to finish installation. It also sees if `api.openshift.com/noalerts` label is set on the `ClusterDeployment` of the new cluster being provisioned.
* The `api.openshift.com/noalerts` label is used to disable alerts from the provisioned cluster. This label is typically used on test clusters that do not require immediate attention as a result of critical issues or outages. Therefore, PagerDuty does not continue its actions if it finds this label in the new cluster's `ClusterDeployment`.
* Once the `installed` field becomes true, PagerDuty creates a secret which contains the integration key required to communicate with PagerDuty Web application.
* The PagerDuty operator then creates [syncset](https://github.com/openshift/hive/blob/master/config/crds/hive_v1_syncset.yaml) with the relevant information for hive to send the PagerDuty secret to the newly provisioned cluster .
* This syncset is used by hive to deploy the pagerduty secret to the provisioned cluster so that the relevant SRE team get notified of alerts on the cluster.
* The pagerduty secret is deployed to the coordinates specified in the `spec.targetSecretRef` field of the PagerDutyIntegration CR.
* This syncset is used by hive to deploy the pagerduty secret to the provisioned cluster so that Openshift SRE can be alerted in case of issues on the cluster.
* Generally, the pagerduty secret is deployed under the `openshift-monitoring` namespace and named `pd-secret` on the new cluster.

## Development

Expand All @@ -36,17 +36,20 @@ $ oc apply -f manifests/01-namespace.yaml
$ oc apply -f manifests/02-role.yaml
$ oc apply -f manifests/03-service_account.yaml
$ oc apply -f manifests/04-role_binding.yaml
$ oc apply -f deploy/crds/pagerduty_v1alpha1_pagerdutyintegration_crd.yaml
```


Create secret with pagerduty api key, for example using a [trial account](https://www.pagerduty.com/free-trial/). You can then create an API key at https://<your-account>.pagerduty.com/api_keys.
Create secret with pagerduty api key, for example using a [trial account](https://www.pagerduty.com/free-trial/). You can then create an API key at https://<your-account>.pagerduty.com/api_keys. Also, you need to create the ID of you escalation policy. You can get this by clicking on your policy at https://<your-account>.pagerduty.com/escalation_policies#. The ID will afterwards be visible in the URL behind the `#` character.
Following is an example secret to adjust and apply with `oc apply -f <filename>`.

```yaml
apiVersion: v1
data:
ACKNOWLEDGE_TIMEOUT: MjE2MDA=
ESCALATION_POLICY: MTIzNA== #echo -n <escalation-policy-id> | base64
PAGERDUTY_API_KEY: bXktYXBpLWtleQ== #echo -n <pagerduty-api-key> | base64
RESOLVE_TIMEOUT: MA==
SERVICE_PREFIX: b3Nk
kind: Secret
metadata:
name: pagerduty-api-key
Expand All @@ -67,7 +70,7 @@ Create namespace `pagerduty-operator`.
$ oc create namespace pagerduty-operator
```

Continue to `Create PagerDutyIntegration`.
Continue to `Create ClusterDeployment`.

### Option 2: Run local built operator in minishift

Expand Down Expand Up @@ -113,22 +116,26 @@ Create a copy of `manifests/05-operator.yaml` and modify it use your image from
Deploy modified operator manifest

```terminal
$ oc apply -f path/to/modified/operator.yaml
$ oc apply -f path/to/modified/operator.yaml
```
### Create PagerDutyIntegration

There's an example at
`deploy/examples/pagerduty_v1alpha1_pagerdutyintegration_cr.yaml` that
you can edit and apply to your cluster.
### Create ClusterDeployment

You'll need to use a valid escalation policy ID from your PagerDuty account. You
can get this by clicking on your policy at
https://<your-account>.pagerduty.com/escalation_policies#. The ID will be
visible in the URL after the `#` character.
`pagerduty-operator` doesn't start reconciling clusters until `status.installed` is set to `true`. To be able to set this variable via `oc edit` without actually deploying a cluster to AWS, the ClusterDeployment CRD needs to be adjusted.

### Create ClusterDeployment
```terminal
$ oc edit crd clusterdeployments.hive.openshift.io
```

`pagerduty-operator` doesn't start reconciling clusters until `spec.installed` is set to `true`.
Remove `subsesource` part:

```
spec:
[...]
subresources: ## delete me
status: {} ## delete me
[...]
```

Create ClusterDeployment.

Expand All @@ -137,7 +144,7 @@ $ oc create namespace fake-cluster-namespace
$ oc apply -f hack/clusterdeployment/fake-clusterdeployment.yml
```

If present, set `spec.installed` to true.
If present, set `status.installed` to true.

```terminal
$ oc edit clusterdeployment fake-cluster -n fake-cluster-namespace
Expand Down
12 changes: 3 additions & 9 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ const (
PagerDutyAPISecretName string = "pagerduty-api-key"
PagerDutyAPISecretKey string = "PAGERDUTY_API_KEY"
OperatorFinalizer string = "pd.managed.openshift.io/pagerduty"
SecretSuffix string = "-pd-secret"
ConfigMapSuffix string = "-pd-config"
SyncSetPostfix string = "-pd-sync"
PagerDutySecretName string = "pd-secret"
ConfigMapPostfix string = "-pd-config"

// PagerDutyUrgencyRule is the type of IncidentUrgencyRule for new incidents
// coming into the Service. This is for the creation of NEW SERVICES ONLY
Expand All @@ -38,10 +39,3 @@ const (
// ClusterDeploymentNoalertsLabel is the label the clusterdeployment will have if the cluster should not send alerts
ClusterDeploymentNoalertsLabel string = "api.openshift.com/noalerts"
)

// Name is used to generate the name of secondary resources (SyncSets,
// Secrets, ConfigMaps) for a ClusterDeployment that are created by
// the PagerDutyIntegration controller.
func Name(servicePrefix, clusterDeploymentName, suffix string) string {
return servicePrefix + "-" + clusterDeploymentName + suffix
}
136 changes: 0 additions & 136 deletions deploy/crds/pagerduty.openshift.io_pagerdutyintegrations_crd.yaml

This file was deleted.

18 changes: 0 additions & 18 deletions deploy/examples/pagerduty_v1alpha1_pagerdutyintegration_cr.yaml

This file was deleted.

12 changes: 0 additions & 12 deletions hack/generate.sh

This file was deleted.

13 changes: 1 addition & 12 deletions manifests/02-role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,6 @@ apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: pagerduty-operator
rules:
- apiGroups:
- pagerduty.openshift.io
resources:
- pagerdutyintegrations
- pagerdutyintegrations/status
- pagerdutyintegrations/finalizers
verbs:
- get
- list
- watch
- update
- apiGroups:
- ""
resources:
Expand Down Expand Up @@ -74,4 +63,4 @@ rules:
resources:
- routes
verbs:
- '*'
- '*'
10 changes: 0 additions & 10 deletions pkg/apis/addtoscheme_pagerduty_v1alpha1.go

This file was deleted.

4 changes: 0 additions & 4 deletions pkg/apis/pagerduty/v1alpha1/doc.go

This file was deleted.

Loading