From 4ab833a88575aa9335210a408060d815d6d68fb8 Mon Sep 17 00:00:00 2001 From: Leif Madsen Date: Tue, 9 Jun 2020 13:27:43 -0400 Subject: [PATCH] Migrate to apps/v1 API for Deployments (#50) * Migrate to apps/v1 API for Deployments Closes #46 * Add CSV version 1.0.2 --- ...operator.v1.0.2.clusterserviceversion.yaml | 290 ++++++++++++++++++ ...gateway.infra.watch_smartgateways_crd.yaml | 115 +++++++ .../smart-gateway-operator.package.yaml | 2 +- deploy/role.yaml | 6 - .../smartgateway/templates/deployment.yaml.j2 | 2 +- 5 files changed, 407 insertions(+), 8 deletions(-) create mode 100644 deploy/olm-catalog/smart-gateway-operator/1.0.2/smart-gateway-operator.v1.0.2.clusterserviceversion.yaml create mode 100644 deploy/olm-catalog/smart-gateway-operator/1.0.2/smartgateway.infra.watch_smartgateways_crd.yaml diff --git a/deploy/olm-catalog/smart-gateway-operator/1.0.2/smart-gateway-operator.v1.0.2.clusterserviceversion.yaml b/deploy/olm-catalog/smart-gateway-operator/1.0.2/smart-gateway-operator.v1.0.2.clusterserviceversion.yaml new file mode 100644 index 0000000..14e520e --- /dev/null +++ b/deploy/olm-catalog/smart-gateway-operator/1.0.2/smart-gateway-operator.v1.0.2.clusterserviceversion.yaml @@ -0,0 +1,290 @@ +apiVersion: operators.coreos.com/v1alpha1 +kind: ClusterServiceVersion +metadata: + annotations: + alm-examples: |- + [ + { + "apiVersion": "smartgateway.infra.watch/v2alpha1", + "kind": "SmartGateway", + "metadata": { + "name": "cloud1-events" + }, + "spec": { + "debug": false, + "prefetch": 0, + "resetIndex": false, + "serviceType": "events", + "size": 1 + } + }, + { + "apiVersion": "smartgateway.infra.watch/v2alpha1", + "kind": "SmartGateway", + "metadata": { + "name": "cloud1-metrics" + }, + "spec": { + "debug": false, + "prefetch": 15000, + "serviceType": "metrics", + "size": 1, + "useTimestamp": true + } + } + ] + capabilities: Basic Install + categories: Monitoring + certified: "false" + containerImage: quay.io/infrawatch/smart-gateway-operator:v1.0.2 + createdAt: "2019-11-14T14:49:00Z" + description: Smart Gateway Operator + repository: https://github.com/infrawatch/smart-gateway-operator + support: Red Hat (CloudOps) + name: smart-gateway-operator.v1.0.2 + namespace: placeholder +spec: + apiservicedefinitions: {} + customresourcedefinitions: + owned: + - description: Instance of the Smart Gateway + displayName: SmartGateway + kind: SmartGateway + name: smartgateways.smartgateway.infra.watch + resources: + - kind: Pod + name: "" + version: v1 + - kind: Deployments + name: "" + version: v1 + - kind: ReplicaSets + name: "" + version: v1 + - kind: Services + name: "" + version: v1 + - kind: ConfigMaps + name: "" + version: v1 + - kind: SmartGateways + name: "" + version: v2alpha1 + specDescriptors: + - description: Number of Smart Gateways to deploy + displayName: Size + path: size + x-descriptors: + - urn:alm:descriptor:com.tectonic.ui:number + - description: Location of the AMQP endpoint to connect the Smart Gateway to + displayName: AMQP URL + path: amqpUrl + x-descriptors: + - urn:alm:descriptor:com.tectonic.ui:text + - description: Container image path + displayName: Container image path + path: containerImagePath + x-descriptors: + - urn:alm:descriptor:com.tectonic.ui:text + - description: Number of messages that we can prefetch from AMQP 1.x. By enabling + prefetching, the smart gateway won't need to request every message individually + from the AMQP bus, resulting in a round trip for every request between sender + and receiver. To avoid the round trip for every message, the use of prefetch + can be used to allow the receiver to request messages be sent in anticipation + of them being sent to us. + displayName: Prefetch + path: prefetch + x-descriptors: + - urn:alm:descriptor:com.tectonic.ui:number + - description: Use the source timestamp (time when data was collected) rather + than let Prometheus write when the data was scraped for that metric. + displayName: Use Timestamp + path: useTimestamp + x-descriptors: + - urn:alm:descriptor:com.tectonic.ui:booleanSwitch + - description: Smart Gateway Service Type + displayName: Service Type + path: serviceType + x-descriptors: + - urn:alm:descriptor:com.tectonic.ui:select:metrics + - urn:alm:descriptor:com.tectonic.ui:select:events + - description: Enable additional debugging information to console output + displayName: Enable debugging + path: debug + x-descriptors: + - urn:alm:descriptor:tectonic.ui:booleanSwitch + statusDescriptors: + - description: Conditions provided by deployment + displayName: Conditions + path: conditions + x-descriptors: + - urn:alm:descriptor:io.kubernetes.conditions + version: v2alpha1 + description: |- + # Smart Gateway for Service Telemetry Framework + + The Smart Gateway is middleware for OpenShift that takes metrics and events + data streams from an AMQP 1.x message bus, and provides a method to having + that data stream stored within Prometheus or ElasticSearch. + + ## Core capabilities + + The Smart Gateway provides two modes: + + * metrics: provides an HTTP scrape endpoint for Prometheus + * events: writes events directly to an ElasticSearch endpoint + + ## Operator features + + * **Two Service Types** - Supports the `metrics` and `events` service types which defines the type of Smart Gateway to be deployed + + * **Configuration** - Configuration of the Smart Gateway to allow for it to be connected to an AMQP 1.x bus and pointed at the appropriate storage mechanism based on service type. + + ## Before getting started + + 1. Ensure an AMQP 1.x bus has been setup (such as AMQ Interconnect) + 2. If the Smart Gateway is running in events mode, be sure the ElasticSearch Operator and ElasticSearch instance have been pre-deployed. + displayName: Smart Gateway Operator + icon: + - base64data: PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjxzdmcKICAgeG1sbnM6ZGM9Imh0dHA6Ly9wdXJsLm9yZy9kYy9lbGVtZW50cy8xLjEvIgogICB4bWxuczpjYz0iaHR0cDovL2NyZWF0aXZlY29tbW9ucy5vcmcvbnMjIgogICB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiCiAgIHhtbG5zOnN2Zz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciCiAgIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICAgeG1sbnM6c29kaXBvZGk9Imh0dHA6Ly9zb2RpcG9kaS5zb3VyY2Vmb3JnZS5uZXQvRFREL3NvZGlwb2RpLTAuZHRkIgogICB4bWxuczppbmtzY2FwZT0iaHR0cDovL3d3dy5pbmtzY2FwZS5vcmcvbmFtZXNwYWNlcy9pbmtzY2FwZSIKICAgaW5rc2NhcGU6dmVyc2lvbj0iMS4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2Zz4K + mediatype: image/svg+xml + install: + spec: + deployments: + - name: smart-gateway-operator + spec: + replicas: 1 + selector: + matchLabels: + app: smart-gateway-operator + strategy: {} + template: + metadata: + labels: + app: smart-gateway-operator + spec: + containers: + - command: + - /usr/local/bin/ao-logs + - /tmp/ansible-operator/runner + - stdout + image: quay.io/infrawatch/smart-gateway-operator:latest + imagePullPolicy: Always + name: ansible + resources: {} + volumeMounts: + - mountPath: /tmp/ansible-operator/runner + name: runner + readOnly: true + - env: + - name: WATCH_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.annotations['olm.targetNamespaces'] + - name: POD_NAME + valueFrom: + fieldRef: + fieldPath: metadata.name + - name: OPERATOR_NAME + value: smart-gateway-operator + - name: ANSIBLE_GATHERING + value: explicit + - name: SMARTGATEWAY_IMAGE + value: quay.io/infrawatch/smart-gateway:latest + image: quay.io/infrawatch/smart-gateway-operator:latest + imagePullPolicy: Always + name: operator + resources: {} + volumeMounts: + - mountPath: /tmp/ansible-operator/runner + name: runner + serviceAccountName: smart-gateway-operator + volumes: + - emptyDir: {} + name: runner + permissions: + - rules: + - apiGroups: + - "" + resources: + - pods + - services + - endpoints + - persistentvolumeclaims + - events + - configmaps + - secrets + verbs: + - '*' + - apiGroups: + - "" + resources: + - namespaces + verbs: + - get + - apiGroups: + - apps + resources: + - deployments + - daemonsets + - replicasets + - statefulsets + verbs: + - '*' + - apiGroups: + - monitoring.coreos.com + resources: + - servicemonitors + verbs: + - get + - create + - list + - patch + - watch + - apiGroups: + - apps + resourceNames: + - smart-gateway-operator + resources: + - deployments/finalizers + verbs: + - update + - apiGroups: + - smartgateway.infra.watch + resources: + - '*' + verbs: + - '*' + serviceAccountName: smart-gateway-operator + strategy: deployment + installModes: + - supported: true + type: OwnNamespace + - supported: true + type: SingleNamespace + - supported: false + type: MultiNamespace + - supported: true + type: AllNamespaces + keywords: + - servicetelemetry + - monitoring + - telemetry + - notifications + - smartgateway + labels: + name: smart-gateway-operator + links: + - name: Source Code + url: https://github.com/infrawatch/smart-gateway-operator + maintainers: + - email: support@redhat.com + name: Red Hat CloudOps DFG + maturity: alpha + provider: + name: Red Hat + replaces: smart-gateway-operator.v1.0.1 + selector: + matchLabels: + name: smart-gateway-operator + version: 1.0.2 diff --git a/deploy/olm-catalog/smart-gateway-operator/1.0.2/smartgateway.infra.watch_smartgateways_crd.yaml b/deploy/olm-catalog/smart-gateway-operator/1.0.2/smartgateway.infra.watch_smartgateways_crd.yaml new file mode 100644 index 0000000..244f272 --- /dev/null +++ b/deploy/olm-catalog/smart-gateway-operator/1.0.2/smartgateway.infra.watch_smartgateways_crd.yaml @@ -0,0 +1,115 @@ +apiVersion: apiextensions.k8s.io/v1beta1 +kind: CustomResourceDefinition +metadata: + name: smartgateways.smartgateway.infra.watch +spec: + group: smartgateway.infra.watch + names: + kind: SmartGateway + listKind: SmartGatewayList + plural: smartgateways + singular: smartgateway + scope: Namespaced + version: v2alpha1 + subresources: + status: {} + versions: + - name: v2alpha1 + served: true + storage: true + validation: + openAPIV3Schema: + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + spec: + description: 'SmartGatewaySpec is a specification of the desired behavior + of the Smartgateway deployment. More info: https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#spec-and-status' + properties: + size: + description: Size sets the number of replicas to create. Defaults to 1. + type: integer + amqpUrl: + description: AMQP1.x listener example 127.0.0.1:5672/collectd/telemetry. Defaults to using + 'messaging-internal-..src:5672/collectd/telemetry'. + type: string + amqpDataSource: + description: The expected data source of the messages received from the address configured in amqpUrl. Available values include 'universal', 'collectd', and 'ceilometer'. + type: string + useBasicAuth: + description: Whether to use basic authentication or not when connecting to ElasticSearch. Default is 'false' + type: boolean + elasticUrl: + description: URL for ElasticSearch endpoing to connect when the Smart Gateway is operating as an 'events' service type. + Defaults to 'elasticsearch-es-http..svc:9200'. + type: string + elasticUser: + description: Basic Authentication username for ElasticSearch. + type: string + elasticPass: + description: Basic Authentication password for ElasticSearch. + type: string + tlsSecretName: + description: Name of the Secret object that holds the TLS certificates and key for Elasticsearch. + Defaults to 'elasticsearch-es-cert'. + resetIndex: + description: Reset the ElasticSearch index on load. Defaults to 'false'. + type: boolean + serviceType: + description: The service type for this smart gateway. One of 'metrics' or 'events'. Defaults to 'metrics'. + type: string + exporterHost: + description: Metrics URL for Prometheus to export. Defaults to "0.0.0.0". + type: string + exporterPort: + description: Metrics port for Prometheus to export. Defaults to 8081. + type: integer + cpuStats: + description: Include CPU usage info in http requests (degrades performance). Defaults to 'false'. + type: boolean + dataCount: + description: Stop after receiving this many messages in total (-1 forever). Defaults to '-1'. + type: integer + debug: + description: Enable verbose debugging statements. Defaults to 'false'. + type: boolean + prefetch: + description: Number of messages that we can prefetch from AMQP 1.x. By enabling prefetching, the smart gateway won't need to + request every message individually from the AMQP bus, resulting in a round trip for every request between sender and receiver. + To avoid the round trip for every message, the use of prefetch can be used to allow the receiver to request messages be sent + in anticipation of them being sent to us. + type: integer + containerImagePath: + description: Path to the container image this Operator will deploy. Value is defined as the standard registry/image_name:tag + format. + type: string + useTimestamp: + description: Use the source timestamp (time when data was collected) rather than let Prometheus write when the data was + scraped for that metric. + type: boolean + status: + description: Status results of an instance of Smart Gateway + properties: + conditions: + description: The resulting conditions when a Smart Gateway is instantiated + items: + properties: + status: + type: string + type: + type: string + reason: + type: string + lastTransitionTime: + type: string + type: object + type: array + type: object diff --git a/deploy/olm-catalog/smart-gateway-operator/smart-gateway-operator.package.yaml b/deploy/olm-catalog/smart-gateway-operator/smart-gateway-operator.package.yaml index 43eee95..4109fca 100644 --- a/deploy/olm-catalog/smart-gateway-operator/smart-gateway-operator.package.yaml +++ b/deploy/olm-catalog/smart-gateway-operator/smart-gateway-operator.package.yaml @@ -1,5 +1,5 @@ channels: -- currentCSV: smart-gateway-operator.v1.0.1 +- currentCSV: smart-gateway-operator.v1.0.2 name: stable defaultChannel: stable packageName: smartgateway-operator diff --git a/deploy/role.yaml b/deploy/role.yaml index 096e902..1a256d3 100644 --- a/deploy/role.yaml +++ b/deploy/role.yaml @@ -22,12 +22,6 @@ rules: - namespaces verbs: - get -- apiGroups: - - extensions - resources: - - deployments - verbs: - - '*' - apiGroups: - apps resources: diff --git a/roles/smartgateway/templates/deployment.yaml.j2 b/roles/smartgateway/templates/deployment.yaml.j2 index b19c0cb..2cdbe74 100644 --- a/roles/smartgateway/templates/deployment.yaml.j2 +++ b/roles/smartgateway/templates/deployment.yaml.j2 @@ -1,4 +1,4 @@ -apiVersion: extensions/v1beta1 +apiVersion: apps/v1 kind: Deployment metadata: name: '{{ meta.name }}-smartgateway'