Initial commit for snmp-armada-app skeleton

This is the initial commit for the app skeleton.

- centos files: files related with the infra and docker images
- rst files: files with doc about snmp-armada-app
- stx-snmp-helm folder: files related with helm charts and
  the app creation

Story: 2008132
Task: 41122

Change-Id: I0c4b9843544228bb04cb26504674134dd0e3ceb8
Signed-off-by: Nicolas Alvarez <nicolas.alvarez@windriver.com>
This commit is contained in:
Nicolas Alvarez 2020-10-19 15:01:49 -03:00
parent 2b8c8588d8
commit 78bdafbbde
29 changed files with 411 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.vscode/

16
CONTRIBUTING.rst Normal file
View File

@ -0,0 +1,16 @@
If you would like to contribute to the development of OpenStack,
you must follow the steps in this page:
https://docs.openstack.org/infra/manual/developers.html
Once those steps have been completed, changes to OpenStack
should be submitted for review via the Gerrit tool, following
the workflow documented at:
https://docs.openstack.org/infra/manual/developers.html#development-workflow
Pull requests submitted through GitHub will be ignored.
Bugs should be filed in Launchpad:
https://bugs.launchpad.net/starlingx

17
HACKING.rst Normal file
View File

@ -0,0 +1,17 @@
StarlingX SNMP-Armada-App Style Commandments
================================================================
- Step 1: Read the OpenStack style commandments
https://docs.openstack.org/hacking/latest/
- Step 2: Read on
Snmp-Armada-App Specific Commandments
---------------------------------------------------------
None so far
Running tests
-------------
The approach to running tests is to simply run the command ``tox``. This will
create virtual environments, populate them with dependencies and run all of
the tests that OpenStack CI systems run.

1
centos_build_layer.cfg Normal file
View File

@ -0,0 +1 @@
flock

1
centos_iso_image.inc Normal file
View File

@ -0,0 +1 @@
stx-snmp-helm

1
centos_pkg_dirs Normal file
View File

@ -0,0 +1 @@
stx-snmp-helm

View File

@ -0,0 +1 @@
stx-snmp-helm

View File

@ -0,0 +1 @@
stx-snmp-helm

12
config Normal file
View File

@ -0,0 +1,12 @@
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
url = https://review.opendev.org/starlingx/snmp-armada-app.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
rebase = true

2
github_sync.trigger Normal file
View File

@ -0,0 +1,2 @@
# to trigger the upload job to sync to GitHub
1

View File

@ -0,0 +1,7 @@
SRC_DIR="stx-snmp-helm"
TAR_NAME=helm-charts-snmp-0-1-0
VERSION=1.0.0
TAR="$TAR_NAME.tar.gz"
TIS_PATCH_VER=PKG_GITREVCOUNT

View File

@ -0,0 +1,6 @@
FROM centos:8
RUN yum -y update
RUN yum -y install net-snmp
EXPOSE 161/udp
CMD [ "/usr/sbin/snmpd", "-f"]

View File

@ -0,0 +1,71 @@
# Application tunables (maps to metadata)
%global app_name snmp
%global helm_repo stx-platform
%global armada_folder /usr/lib/armada
# Install location
%global app_folder /usr/local/share/applications/helm
# Build variables
%global helm_folder /usr/lib/helm
%global toolkit_version 0.1.0
Summary: StarlingX SNMP Armada Helm Charts
Name: stx-snmp-helm
Version: 1.0
Release: %{tis_patch_ver}%{?_tis_dist}
License: Apache-2.0
Group: base
Packager: Wind River <info@windriver.com>
URL: unknown
Source0: helm-charts-snmp-0-1-0.tar.gz
BuildArch: noarch
BuildRequires: helm
%description
StarlingX SNMP Helm Charts
%prep
%setup -n helm-charts-snmp-0-1-0-1.0.0
%build
cd helm-charts
make
cd -
# Create a chart tarball compliant with sysinv kube-app.py
%define app_staging %{_builddir}/staging
%define app_tarball %{app_name}-%{version}-%{tis_patch_ver}.tgz
# Setup staging
mkdir -p %{app_staging}
cp files/metadata.yaml %{app_staging}
cp manifests/*.yaml %{app_staging}
mkdir -p %{app_staging}/charts
cp helm-charts/*.tgz %{app_staging}/charts
cd %{app_staging}
# Populate metadata
sed -i 's/@APP_NAME@/%{app_name}/g' %{app_staging}/metadata.yaml
sed -i 's/@APP_VERSION@/%{version}-%{tis_patch_ver}/g' %{app_staging}/metadata.yaml
sed -i 's/@HELM_REPO@/%{helm_repo}/g' %{app_staging}/metadata.yaml
# package it up
find . -type f ! -name '*.md5' -print0 | xargs -0 md5sum > checksum.md5
tar -zcf %{_builddir}/%{app_tarball} -C %{app_staging}/ .
# Cleanup staging
rm -fr %{app_staging}
%install
install -d -m 755 %{buildroot}/%{app_folder}
install -p -D -m 755 %{_builddir}/%{app_tarball} %{buildroot}/%{app_folder}
%files
%defattr(-,root,root,-)
%{app_folder}/*

View File

@ -0,0 +1,2 @@
BUILDER=docker
LABEL=stx-snmp

View File

@ -0,0 +1,5 @@
This directory contains all StarlingX charts that need to be built for this
application. Some charts are common across applications. These common charts
reside in the stx-config/kubernetes/helm-charts directory. To include these in
this application update the build_srpm.data file and use the COPY_LIST_TO_TAR
mechanism to populate these common charts.

View File

@ -0,0 +1,3 @@
apiVersion: v1
entries: {}
generated: 2019-01-07T12:33:46.098166523-06:00

View File

@ -0,0 +1,5 @@
maintain_user_overrides: true
app_name: @APP_NAME@
app_version: @APP_VERSION@
helm_repo: @HELM_REPO@

View File

@ -0,0 +1,11 @@
apiVersion: v1
generated: 2019-01-02T15:19:36.215111369-06:00
repositories:
- caFile: ""
cache: /builddir/.helm/repository/cache/local-index.yaml
certFile: ""
keyFile: ""
name: local
password: ""
url: http://127.0.0.1:8879/charts
username: ""

View File

@ -0,0 +1,43 @@
#
# Copyright 2017 The Openstack-Helm Authors.
#
# Copyright (c) 2019 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
# It's necessary to set this because some environments don't link sh -> bash.
SHELL := /bin/bash
TASK := build
EXCLUDES := helm-toolkit doc tests tools logs tmp
CHARTS := helm-toolkit $(filter-out $(EXCLUDES), $(patsubst %/.,%,$(wildcard */.)))
.PHONY: $(EXCLUDES) $(CHARTS)
all: $(CHARTS)
$(CHARTS):
@if [ -d $@ ]; then \
echo; \
echo "===== Processing [$@] chart ====="; \
make $(TASK)-$@; \
fi
init-%:
if [ -f $*/Makefile ]; then make -C $*; fi
if [ -f $*/requirements.yaml ]; then helm dep up $*; fi
lint-%: init-%
if [ -d $* ]; then helm lint $*; fi
build-%:
if [ -d $* ]; then helm package $*; fi
clean:
@echo "Clean all build artifacts"
rm -f */templates/_partials.tpl */templates/_globals.tpl
rm -f *tgz */charts/*tgz */requirements.lock
rm -rf */charts */tmpcharts
%:
@:

View File

@ -0,0 +1,22 @@
# 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
.vscode/

View File

@ -0,0 +1,5 @@
apiVersion: v1
appVersion: "1.0"
description: SNMP service
name: snmp
version: 1.0.0

View File

@ -0,0 +1,7 @@
# incl/excl subtree mask
view all included .1 80
agentAddress udp:161
sysObjectID 1.3.6.1.4.1.731.3
sysServices 72

View File

@ -0,0 +1,6 @@
1. This is SNMP deployment with extended MIB:
This charts starts:
- Create config map for /etc/snmp/snmpd.conf
- Deploy snmpd
- Create service for port for snmp get
- Deploy sub agent for extended MIB

View File

@ -0,0 +1,33 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "snmp.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 "snmp.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 -}}
{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "snmp.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

View File

@ -0,0 +1,7 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Values.configmap.name_snmpd }}
data:
{{ (.Files.Glob "snmpd/*").AsConfig | indent 2 }}
---

View File

@ -0,0 +1,37 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "snmp.fullname" . }}
labels:
app.kubernetes.io/name: {{ include "snmp.name" . }}
helm.sh/chart: {{ include "snmp.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app.kubernetes.io/name: {{ include "snmp.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
template:
metadata:
labels:
app.kubernetes.io/name: {{ include "snmp.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
spec:
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- containerPort: 161
protocol: UDP
- containerPort: 162
protocol: UDP
volumeMounts:
- name: snmpd-etc-volume
mountPath: /etc/snmp
volumes:
- name: snmpd-etc-volume
configMap:
name: {{ .Values.configmap.name_snmpd }}

View File

@ -0,0 +1,19 @@
apiVersion: v1
kind: Service
metadata:
name: {{ .Values.service.name }}
labels:
app.kubernetes.io/name: {{ include "snmp.name" . }}
helm.sh/chart: {{ include "snmp.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
spec:
type: {{ .Values.service.type }}
ports:
- name: port-1
port: 161
protocol: UDP
targetPort: 161
selector:
app.kubernetes.io/name: {{ include "snmp.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}

View File

@ -0,0 +1,24 @@
# Default values for snmp.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
replicaCount: 1
image:
repository: registry.local:9001/local/snmp
tag: 1.0.0
pullPolicy: IfNotPresent
nameOverride: ""
fullnameOverride: ""
configmap:
name_snmpd: snmpd-etc-config
deployment:
master_agent_host: localhost
service:
name: snmpd-service
type: NodePort

View File

@ -0,0 +1,45 @@
---
schema: armada/Chart/v1
metadata:
schema: metadata/Document/v1
name: snmp
data:
chart_name: snmp
release: snmp
namespace: kube-system
source:
location: http://172.17.0.1:8080/helm_charts/stx-platform/snmp-1.0.0.tgz
subpath: snmp
type: tar
reference: master
wait:
timeout: 1800
install:
no_hooks: false
upgrade:
no_hooks: false
pre:
delete:
- type: job
labels:
app: snmp
dependencies: []
---
schema: armada/ChartGroup/v1
metadata:
schema: metadata/Document/v1
name: snmp
data:
description: "StarlingX SNMP"
sequenced: false
chart_group:
- snmp
---
schema: armada/Manifest/v1
metadata:
schema: metadata/Document/v1
name: snmp-manifest
data:
release_prefix: ns
chart_groups:
- snmp