From c3d0415192072a504411afafc3876bc38d4d7377 Mon Sep 17 00:00:00 2001 From: Jeff Billimek Date: Fri, 22 Jun 2018 23:42:09 -0400 Subject: [PATCH] adding comcast chart --- README.md | 13 ++--- comcast/.helmignore | 23 +++++++++ comcast/Chart.yaml | 16 ++++++ comcast/OWNERS | 4 ++ comcast/README.md | 83 +++++++++++++++++++++++++++++++ comcast/templates/NOTES.txt | 7 +++ comcast/templates/_helpers.tpl | 27 ++++++++++ comcast/templates/configmap.yaml | 32 ++++++++++++ comcast/templates/deployment.yaml | 43 ++++++++++++++++ comcast/values.yaml | 36 ++++++++++++++ 10 files changed, 275 insertions(+), 9 deletions(-) create mode 100644 comcast/.helmignore create mode 100644 comcast/Chart.yaml create mode 100644 comcast/OWNERS create mode 100644 comcast/README.md create mode 100644 comcast/templates/NOTES.txt create mode 100644 comcast/templates/_helpers.tpl create mode 100644 comcast/templates/configmap.yaml create mode 100644 comcast/templates/deployment.yaml create mode 100644 comcast/values.yaml diff --git a/README.md b/README.md index 5710cf21..9c72ebf2 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,8 @@ # personal helm charts -See [instructions](https://andrewlock.net/how-to-create-a-helm-chart-repository-using-amazon-s3/) and [helm s3 plugin repo](https://github.com/hypnoglow/helm-s3) - ## Installation -```bash -helm plugin install https://github.com/hypnoglow/helm-s3.git -source .env -helm s3 init s3://public/charts -``` - - +```console +helm repo add billimek https://raw.githubusercontent.com/billimek/helm-repo/master +helm search billimek +``` \ No newline at end of file diff --git a/comcast/.helmignore b/comcast/.helmignore new file mode 100644 index 00000000..a9fe7278 --- /dev/null +++ b/comcast/.helmignore @@ -0,0 +1,23 @@ +# 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 +# OWNERS file for Kubernetes +OWNERS \ No newline at end of file diff --git a/comcast/Chart.yaml b/comcast/Chart.yaml new file mode 100644 index 00000000..480cb74d --- /dev/null +++ b/comcast/Chart.yaml @@ -0,0 +1,16 @@ +apiVersion: v1 +name: comcast +version: 1.0.0 +appVersion: 1.0.0 +description: periodic comcast data usage checks and save the results to InfluxDB +keywords: +- comcast +- influxdb +- xfinity +home: https://github.com/billimek/comcastUsage-for-influxdb +sources: +- https://github.com/billimek/comcastUsage-for-influxdb +- https://github.com/billimek/billimek-charts +maintainers: +- name: billimek + email: jeff@billimek.com \ No newline at end of file diff --git a/comcast/OWNERS b/comcast/OWNERS new file mode 100644 index 00000000..51f88652 --- /dev/null +++ b/comcast/OWNERS @@ -0,0 +1,4 @@ +approvers: +- billimek +reviewers: +- billimek \ No newline at end of file diff --git a/comcast/README.md b/comcast/README.md new file mode 100644 index 00000000..4758a2dd --- /dev/null +++ b/comcast/README.md @@ -0,0 +1,83 @@ +# Comcast Data Cap Usage Collector For InfluxDB and Grafana** + +![Screenshot](https://github.com/billimek/comcastUsage-for-influxdb/raw/master/images/comcast_grafana_example.png) + +This tool allows you to run periodic comcast data usage checks and save the results to Influxdb + +## TL;DR; + +```console +$ helm repo add billimek https://raw.githubusercontent.com/billimek/helm-repo/master +$ helm install billimek/comcast +``` + +## Introduction + +This code is adopted from the work done by [barrycarey](https://github.com/barrycarey) in the [similar thing for capturing speedtest data](https://github.com/barrycarey/Speedtest-for-InfluxDB-and-Grafana) as well as [jantman's](https://github.com/jantman) [xfinity-usage python example](https://github.com/jantman/xfinity-usage) + +## Installing the Chart + +To install the chart with the release name `my-release`: + +```console +$ helm install --name my-release billimek/comcast +``` +## Uninstalling the Chart + +To uninstall/delete the `my-release` deployment: + +```console +$ helm delete my-release --purge +``` + +The command removes all the Kubernetes components associated with the chart and deletes the release. + +## Configuration + +The configuration is set as a block of text through a configmap and mouted as a file in /src/config.ini Any value in this text block should match the defined Comcast configuration. There are several values here that will have to match our kubernetes configuration. + +## Configuration + +The following tables lists the configurable parameters of the Sentry chart and their default values. + +| Parameter | Description | Default | +| ------------------------------- | ------------------------------- | ---------------------------------------------------------- | +| `image.repository` | Comcast image | `billimek/comcastusage-for-influxdb` | +| `image.tag` | Comcast image tag | `latest` | +| `image.pullPolicy` | Comcast image pull policy | `IfNotPresent` | +| `debug` | Display debugging output | `false` | +| `config.delay` | how many seconds to wait between checks | `3600` | +| `config.influxdb.host` | InfluxDB hostname | `influxdb-influxdb` | +| `config.influxdb.port` | InfluxDB port | `8086` | +| `config.influxdb.database` | InfluxDB database | `comcast` | +| `config.influxdb.username` | InfluxDB username | `` | +| `config.influxdb.password` | InfluxDB password | `` | +| `config.influxdb.ssl` | InfluxDB connection using SSL | `false` | +| `config.comcast.username` | Comcast website login usernma | `someuser` | +| `config.comcast.password` | Comcast website login password | `somepassword` | + +Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example, + +```console +$ helm install --name my-release \ + --set config.comcast.username=tonystark,config.comcast.password=mypassword \ + billimek/comcast +``` + +Alternatively, a YAML file that specifies the values for the above parameters can be provided while installing the chart. For example, + +```console +$ helm install --name my-release -f values.yaml billimek/comcast +``` + +Read through the [values.yaml](values.yaml) file. It has several commented out suggested values. + +## InfluxDB metrics +``` +'measurement': 'comcast_data_usage', +'fields': { + 'used', + 'total', + 'unit' +} +``` \ No newline at end of file diff --git a/comcast/templates/NOTES.txt b/comcast/templates/NOTES.txt new file mode 100644 index 00000000..08094752 --- /dev/null +++ b/comcast/templates/NOTES.txt @@ -0,0 +1,7 @@ +You can connect to the container running comcast. To open a shell session in the pod run the following: + +- kubectl exec -i -t --namespace {{ .Release.Namespace }} $(kubectl get pods --namespace {{ .Release.Namespace }} -l app={{ template "comcast.fullname" . }} -o jsonpath='{.items[0].metadata.name}') /bin/sh + +To trail the logs for the comcast pod run the following: + +- kubectl logs -f --namespace {{ .Release.Namespace }} $(kubectl get pods --namespace {{ .Release.Namespace }} -l app={{ template "comcast.fullname" . }} -o jsonpath='{ .items[0].metadata.name }') \ No newline at end of file diff --git a/comcast/templates/_helpers.tpl b/comcast/templates/_helpers.tpl new file mode 100644 index 00000000..0289f6df --- /dev/null +++ b/comcast/templates/_helpers.tpl @@ -0,0 +1,27 @@ +{{/* vim: set filetype=mustache: */}} + +{{/* +Expand the name of the chart. +*/}} +{{- define "comcast.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} +{{- end -}} + + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "comcast.fullname" -}} +{{- if .Values.fullnameOverride -}} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- $name := default .Chart.Name .Values.nameOverride -}} +{{- if contains $name .Release.Name -}} +{{- .Release.Name | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} +{{- end -}} +{{- end -}} +{{- end -}} \ No newline at end of file diff --git a/comcast/templates/configmap.yaml b/comcast/templates/configmap.yaml new file mode 100644 index 00000000..4fe2cdc4 --- /dev/null +++ b/comcast/templates/configmap.yaml @@ -0,0 +1,32 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ template "comcast.fullname" . }} + labels: + app: {{ template "comcast.name" . }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" + release: "{{ .Release.Name }}" + heritage: "{{ .Release.Service }}" +data: + config.ini: | + [GENERAL] + Delay = {{ .Values.config.delay }} + {{- if .Values.debug }} + Output = True + {{- else }} + Output = False + {{- end }} + [INFLUXDB] + Address = {{ .Values.config.influxdb.host }} + Port = {{ .Values.config.influxdb.port }} + Database = {{ .Values.config.influxdb.database }} + Username = {{ .Values.config.influxdb.username }} + Password = {{ .Values.config.influxdb.password }} + {{- if .Values.config.influxdb.ssl }} + Verify_SSL = True + {{- else }} + Verify_SSL = False + {{- end }} + [COMCAST] + Username = {{ .Values.config.comcast.username }} + Password = {{ .Values.config.comcast.password }} \ No newline at end of file diff --git a/comcast/templates/deployment.yaml b/comcast/templates/deployment.yaml new file mode 100644 index 00000000..04a8c041 --- /dev/null +++ b/comcast/templates/deployment.yaml @@ -0,0 +1,43 @@ +apiVersion: extensions/v1beta1 +#apiVersion: apps/v1beta2 +kind: Deployment +metadata: + name: {{ template "comcast.fullname" . }} + labels: + app: {{ template "comcast.name" . }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + selector: + matchLabels: + app: {{ template "comcast.name" . }} + release: {{ .Release.Name }} + replicas: {{ default 1 .Values.replicas }} + template: + metadata: + labels: + app: {{ template "comcast.name" . }} + release: {{ .Release.Name }} + spec: + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + resources: +{{ toYaml .Values.resources | indent 12 }} + volumeMounts: + - name: {{ template "comcast.name" . }} + mountPath: /src/config.ini + subPath: config.ini + {{- if .Values.nodeSelector }} + nodeSelector: +{{ toYaml .Values.nodeSelector | indent 8 }} + {{- end }} + volumes: + - name: {{ template "comcast.name" . }} + configMap: + name: {{ template "comcast.fullname" . }} + items: + - key: config.ini + path: config.ini \ No newline at end of file diff --git a/comcast/values.yaml b/comcast/values.yaml new file mode 100644 index 00000000..d83b3384 --- /dev/null +++ b/comcast/values.yaml @@ -0,0 +1,36 @@ +# Default values for comcast. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. +replicaCount: 1 +image: + repository: billimek/comcastusage-for-influxdb + tag: latest + pullPolicy: IfNotPresent +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi +nodeSelector: {} +debug: false +config: + # how many seconds to wait between checks + delay: 3600 + influxdb: + # host/port/database are mandatory - change as needed + host: influxdb-influxdb + port: 8086 + database: comcast + # username: + # password: + ssl: false + comcast: + # username/password are mandatory and must be populated + username: someuser + password: somepassword \ No newline at end of file