Skip to content
Snippets Groups Projects
Commit 387fe1e6 authored by garciadeblas's avatar garciadeblas
Browse files

Update fb_magma_knf to fix issues in orc8r helm chart


Signed-off-by: default avatargarciadeblas <gerardo.garciadeblas@telefonica.com>
parent f293be5e
No related tags found
No related merge requests found
Pipeline #14590 failed with stage
Showing
with 802 additions and 0 deletions
# Copyright (c) 2018-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree. An additional grant
# of patent rights can be found in the PATENTS file in the same directory.
{{/*
Chart for a legacy open service for gateway bootstrapping.
We need this in place because old gateways are configured to connect to
cloud boostrap controller via port 443, not 9444. This service can go away
after all gateways in the field have been upgraded to talk to ports 9443/9444
*/}}
{{ $serviceType := .Values.proxy.service.type }}
apiVersion: v1
kind: Service
metadata:
name: {{ required "Bootstrapping name is required" .Values.proxy.service.name }}
labels:
app.kubernetes.io/component: proxy
{{ include "labels" . | indent 4 }}
{{- with .Values.proxy.service.labels }}
{{ toYaml . | indent 4 }}
{{- end }}
{{- with .Values.proxy.service.annotations }}
annotations:
{{ toYaml . | indent 4 }}
{{- end }}
spec:
selector:
app.kubernetes.io/component: proxy
{{ include "selector-labels" . | indent 4 }}
type: {{ .Values.proxy.service.type }}
ports:
{{- with .Values.proxy.service.port.open }}
- name: open
port: 443
targetPort: {{ .targetPort }}
{{- if (and (eq $serviceType "NodePort") (not (empty .nodePort))) }}
nodePort: {{ .nodePort }}
{{- end }}
{{- end }}
# Copyright (c) 2018-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree. An additional grant
# of patent rights can be found in the PATENTS file in the same directory.
{{/*
Chart for a legacy clientcert-secured service. We need this in place because
old gateways are configured to connect to cloud via port 443, not 9443. This
service can go away after all gateways in the field have been upgraded to
talk to ports 9443/9444.
*/}}
{{ $serviceType := .Values.proxy.service.type }}
apiVersion: v1
kind: Service
metadata:
name: orc8r-clientcert-legacy
labels:
app.kubernetes.io/component: proxy
{{ include "labels" . | indent 4 }}
{{- with .Values.proxy.service.labels }}
{{ toYaml . | indent 4 }}
{{- end }}
{{- with .Values.proxy.service.annotations }}
annotations:
{{ toYaml . | indent 4 }}
{{- end }}
spec:
selector:
app.kubernetes.io/component: proxy
{{ include "selector-labels" . | indent 4 }}
type: {{ .Values.proxy.service.type }}
ports:
{{- with .Values.proxy.service.port.clientcert }}
- name: clientcert
port: 443
targetPort: {{ .targetPort }}
{{- if (and (eq $serviceType "NodePort") (not (empty .nodePort))) }}
nodePort: {{ .nodePort }}
{{- end }}
{{- end }}
\ No newline at end of file
{{/*
Copyright (c) 2018-present, Facebook, Inc.
All rights reserved.
This source code is licensed under the BSD-style license found in the
LICENSE file in the root directory of this source tree. An additional grant
of patent rights can be found in the PATENTS file in the same directory.
*/}}
# Documentation and template from: https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Container-Insights-setup-metrics.html
# One of the pods tend to crashloop due to the node running out of available
# inotify watchers (https://github.com/kubernetes/kubernetes/issues/70324)
{{- if .Values.cloudwatch.create }}
# create cwagent service account and role binding
apiVersion: v1
kind: ServiceAccount
metadata:
name: orc8r-cloudwatch
namespace: {{ .Release.Namespace }}
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: orc8r-cloudwatch-role
rules:
- apiGroups: [""]
resources: ["pods", "nodes", "endpoints"]
verbs: ["list", "watch"]
- apiGroups: ["apps"]
resources: ["replicasets"]
verbs: ["list", "watch"]
- apiGroups: ["batch"]
resources: ["jobs"]
verbs: ["list", "watch"]
- apiGroups: [""]
resources: ["nodes/proxy"]
verbs: ["get"]
- apiGroups: [""]
resources: ["nodes/stats", "configmaps", "events"]
verbs: ["create"]
- apiGroups: [""]
resources: ["configmaps"]
resourceNames: ["cwagent-clusterleader"]
verbs: ["get","update"]
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: orc8r-cloudwatch-role-binding
subjects:
- kind: ServiceAccount
name: orc8r-cloudwatch
namespace: {{ .Release.Namespace }}
roleRef:
kind: ClusterRole
name: orc8r-cloudwatch-role
apiGroup: rbac.authorization.k8s.io
---
# create configmap for cwagent config
apiVersion: v1
data:
# Configuration is in Json format. No matter what configure change you make,
# please keep the Json blob valid.
cwagentconfig.json: |
{
"logs": {
"metrics_collected": {
"kubernetes": {
"metrics_collection_interval": 60
}
}
},
"force_flush_interval": 5
}
kind: ConfigMap
metadata:
name: cwagentconfig
namespace: {{ .Release.Namespace }}
---
# deploy cwagent as daemonset
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: orc8r-cloudwatch
namespace: {{ .Release.Namespace }}
spec:
selector:
matchLabels:
name: orc8r-cloudwatch
template:
metadata:
labels:
name: orc8r-cloudwatch
spec:
containers:
- name: orc8r-cloudwatch
image: amazon/cloudwatch-agent:1.226589.0
resources:
limits:
cpu: 200m
memory: 200Mi
requests:
cpu: 200m
memory: 200Mi
# Please don't change below envs
env:
- name: HOST_IP
valueFrom:
fieldRef:
fieldPath: status.hostIP
- name: HOST_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
- name: K8S_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: CI_VERSION
value: "k8s/1.0.0"
# Please don't change the mountPath
volumeMounts:
- name: cwagentconfig
mountPath: /etc/cwagentconfig
- name: rootfs
mountPath: /rootfs
readOnly: true
- name: dockersock
mountPath: /var/run/docker.sock
readOnly: true
- name: varlibdocker
mountPath: /var/lib/docker
readOnly: true
- name: sys
mountPath: /sys
readOnly: true
- name: devdisk
mountPath: /dev/disk
readOnly: true
volumes:
- name: cwagentconfig
configMap:
name: cwagentconfig
- name: rootfs
hostPath:
path: /
- name: dockersock
hostPath:
path: /var/run/docker.sock
- name: varlibdocker
hostPath:
path: /var/lib/docker
- name: sys
hostPath:
path: /sys
- name: devdisk
hostPath:
path: /dev/disk/
terminationGracePeriodSeconds: 60
serviceAccountName: orc8r-cloudwatch
{{- end }}
{{/*
Copyright (c) 2018-present, Facebook, Inc.
All rights reserved.
This source code is licensed under the BSD-style license found in the
LICENSE file in the root directory of this source tree. An additional grant
of patent rights can be found in the PATENTS file in the same directory.
*/}}
{{- $serviceName := "orc8r-controller" -}}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ $serviceName }}
labels:
app.kubernetes.io/component: controller
{{ include "labels" . | indent 4 }}
spec:
replicas: {{ .Values.controller.replicas }}
selector:
matchLabels:
app.kubernetes.io/component: controller
{{ include "selector-labels" . | indent 6 }}
template:
metadata:
labels:
app.kubernetes.io/component: controller
{{ include "selector-labels" . | indent 8 }}
spec:
{{- with .Values.controller.nodeSelector }}
nodeSelector:
{{ toYaml . | indent 8 }}
{{- end }}
{{- with .Values.controller.tolerations }}
tolerations:
{{ toYaml . | indent 8 }}
{{- end }}
{{- with .Values.controller.affinity }}
affinity:
{{ toYaml . | indent 8 }}
{{- end }}
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{ toYaml . | trimSuffix "\n" | indent 8 }}
{{- end }}
volumes:
- name: certs
secret:
secretName: {{ required "secret.certs must be provided" .Values.secret.certs }}
- name: envdir
secret:
secretName: {{ required "secret.envdir must be provided" .Values.secret.envdir }}
{{- if .Values.secret.configs }}
{{- range $module, $secretName := .Values.secret.configs }}
- name: {{ $secretName }}
secret:
secretName: {{ $secretName }}
{{- end }}
{{- else }}
- name: "empty-configs"
emptyDir: {}
{{- end }}
containers:
- name: {{ $serviceName }}
image: {{ required "controller.image.repository must be provided" .Values.controller.image.repository }}:{{ .Values.controller.image.tag }}
imagePullPolicy: {{ .Values.controller.image.pullPolicy }}
#command: ["/bin/sh", "-c", "/usr/bin/supervisord && echo SLEEPING && /bin/sleep 120 && echo CONFIGURING && /var/opt/magma/bin/accessc add-existing -admin -cert /var/opt/magma/certs/admin_operator.pem admin_operator"]
#command: ["/bin/sh", "-c", "/usr/local/bin/wait-for-it.sh -s -t 30 postgresql:5432 && /var/opt/magma/bin/accessc add-existing -admin -cert /var/opt/magma/certs/admin_operator.pem admin_operator && /usr/bin/supervisord"]
lifecycle:
postStart:
exec:
command: ["/bin/sh", "-c", "/usr/local/bin/wait-for-it.sh -s -t 30 postgresql:5432 && /var/opt/magma/bin/accessc add-existing -admin -cert /var/opt/magma/certs/admin_operator.pem admin_operator"]
volumeMounts:
{{- range tuple "certs" "envdir" }}
- name: {{ . }}
mountPath: /var/opt/magma/{{ . }}
readOnly: true
{{- end }}
{{- if .Values.secret.configs }}
{{- range $module, $secretName := .Values.secret.configs }}
- name: {{ $secretName }}
mountPath: {{ print "/var/opt/magma/configs/" $module }}
readOnly: true
{{- end }}
{{- else }}
- name: "empty-configs"
mountPath: /var/opt/magma/configs
readOnly: true
{{- end }}
ports:
{{- with .Values.controller.service }}
- containerPort: {{ .targetPort }}
{{- range $_, $port := untilStep (.portStart | int) (.portEnd | add1 | int) 1 }}
- containerPort: {{ $port }}
{{- end }}
{{- end }}
env:
- name: DATABASE_SOURCE
valueFrom:
secretKeyRef:
name: {{ $serviceName }}
key: {{ .Values.controller.spec.database.driver }}.connstr
- name: SQL_DRIVER
value: {{ .Values.controller.spec.database.driver }}
- name: SQL_DIALECT
value: {{ .Values.controller.spec.database.sql_dialect }}
# Hostname override for dispatcher
- name: SERVICE_HOST_NAME
valueFrom:
fieldRef:
fieldPath: status.podIP
# Hostname override for metricsd
- name: HOST_NAME
valueFrom:
fieldRef:
fieldPath: status.podIP
- name: USE_NEW_HANDLERS
value: "{{ .Values.controller.migration.new_handlers }}"
- name: USE_NEW_MCONFIGS
value: "{{ .Values.controller.migration.new_mconfigs }}"
- name: NEW_MCONFIGS_WHITELIST
value: {{ .Values.controller.migration.mconfig_whitelist }}
livenessProbe:
tcpSocket:
port: 9081
initialDelaySeconds: 10
periodSeconds: 30
readinessProbe:
tcpSocket:
port: 9081
initialDelaySeconds: 5
periodSeconds: 10
resources:
{{ toYaml .Values.proxy.resources | indent 12 }}
# Copyright (c) 2018-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree. An additional grant
# of patent rights can be found in the PATENTS file in the same directory.
apiVersion: v1
kind: Secret
metadata:
name: orc8r-controller
labels:
app.kubernetes.io/component: controller
{{ include "labels" . | indent 4 }}
type: Opaque
data:
{{- with .Values.controller.spec.database }}
{{ if eq .driver "postgres" }}
{{ .driver }}.connstr: {{ printf "dbname=%s user=%s password=%s host=%s port=%d sslmode=disable" .db .user .pass .host (.port | int) | b64enc | quote }}
{{- end }}
{{ if eq .driver "mysql" }}
{{ .driver }}.connstr: {{ printf "%s:%s@%s(%s:%d)/%s" .user .pass .protocol .host (.port | int) .db | b64enc | quote }}
{{- end }}
{{- end }}
# Copyright (c) 2018-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree. An additional grant
# of patent rights can be found in the PATENTS file in the same directory.
apiVersion: v1
kind: Service
metadata:
name: orc8r-controller
labels:
app.kubernetes.io/component: controller
{{ include "labels" . | indent 4 }}
{{- with .Values.controller.service.labels }}
{{ toYaml . | indent 4}}
{{- end}}
{{- with .Values.controller.service.annotations }}
annotations:
{{ toYaml . | indent 4}}
{{- end }}
spec:
selector:
app.kubernetes.io/component: controller
{{ include "selector-labels" . | indent 4 }}
type: {{ .Values.controller.service.type }}
ports:
{{- with .Values.controller.service }}
- name: web
port: {{ .port }}
targetPort: {{ .targetPort }}
{{- range $i, $port := untilStep (.portStart | int) (.portEnd | add1 | int) 1 }}
- name: port-{{ $i }}
port: {{ $port }}
targetPort: {{ $port }}
{{- end }}
{{- end }}
\ No newline at end of file
{{/*
Copyright (c) 2018-present, Facebook, Inc.
All rights reserved.
This source code is licensed under the BSD-style license found in the
LICENSE file in the root directory of this source tree. An additional grant
of patent rights can be found in the PATENTS file in the same directory.
*/}}
{{- $serviceName := "orc8r-proxy" -}}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ $serviceName }}
labels:
app.kubernetes.io/component: proxy
{{ include "labels" . | indent 4 }}
spec:
replicas: {{ .Values.proxy.replicas }}
selector:
matchLabels:
app.kubernetes.io/component: proxy
{{ include "selector-labels" . | indent 6 }}
template:
metadata:
labels:
app.kubernetes.io/component: proxy
{{ include "selector-labels" . | indent 8 }}
spec:
{{- with .Values.proxy.nodeSelector }}
nodeSelector:
{{ toYaml . | indent 8 }}
{{- end }}
{{- with .Values.proxy.tolerations }}
tolerations:
{{ toYaml . | indent 8 }}
{{- end }}
{{- with .Values.proxy.affinity }}
affinity:
{{ toYaml . | indent 8 }}
{{- end }}
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{ toYaml . | trimSuffix "\n" | indent 8 }}
{{- end }}
volumes:
- name: certs
secret:
secretName: {{ required "secret.certs must be provided" .Values.secret.certs }}
- name: envdir
secret:
secretName: {{ required "secret.envdir must be provided" .Values.secret.envdir }}
containers:
- name: {{ $serviceName }}
image: {{ required "proxy.image.repository must be provided" .Values.proxy.image.repository }}:{{ .Values.proxy.image.tag }}
imagePullPolicy: {{ .Values.proxy.image.pullPolicy }}
volumeMounts:
{{- range tuple "certs" "envdir" }}
- name: {{ . }}
mountPath: /var/opt/magma/{{ . }}
readOnly: true
{{- end }}
ports:
- name: clientcert
containerPort: {{ .Values.proxy.service.port.clientcert.targetPort }}
- name: open
containerPort: {{ .Values.proxy.service.port.open.targetPort }}
env:
- name: PROXY_BACKENDS
value: "orc8r-controller"
- name: CONTROLLER_HOSTNAME
value: {{ required "proxy.spec.hostname must be provided" .Values.proxy.spec.hostname | quote }}
- name: HTTP_PROXY_HOSTNAME
value: {{ .Values.proxy.spec.http_proxy_hostname | quote }}
- name: HTTP_PROXY_BACKEND
value: {{ .Values.proxy.spec.http_proxy_backend | quote }}
- name: HTTP_PROXY_DOCKER_HOSTNAME
value: {{ .Values.proxy.spec.http_proxy_docker_hostname | quote }}
- name: HTTP_PROXY_GITHUB_HOSTNAME
value: {{ .Values.proxy.spec.http_proxy_github_hostname | quote }}
# Hostname override for metricsd
- name: HOST_NAME
valueFrom:
fieldRef:
fieldPath: status.podIP
livenessProbe:
tcpSocket:
port: clientcert
initialDelaySeconds: 10
periodSeconds: 30
readinessProbe:
tcpSocket:
port: clientcert
initialDelaySeconds: 5
periodSeconds: 10
resources:
{{ toYaml .Values.proxy.resources | indent 12 }}
# Copyright (c) 2018-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree. An additional grant
# of patent rights can be found in the PATENTS file in the same directory.
{{ $serviceType := .Values.proxy.service.type }}
apiVersion: v1
kind: Service
metadata:
name: orc8r-proxy
labels:
app.kubernetes.io/component: proxy
{{ include "labels" . | indent 4 }}
{{- with .Values.proxy.service.labels }}
{{ toYaml . | indent 4 }}
{{- end }}
{{- with .Values.proxy.service.annotations }}
annotations:
{{ toYaml . | indent 4 }}
{{- end }}
spec:
selector:
app.kubernetes.io/component: proxy
{{ include "selector-labels" . | indent 4 }}
type: {{ .Values.proxy.service.type }}
ports:
{{- with .Values.proxy.service.port.clientcert }}
- name: clientcert
port: {{ .port }}
targetPort: {{ .targetPort }}
{{- if (and (eq $serviceType "NodePort") (not (empty .nodePort))) }}
nodePort: {{ .nodePort }}
{{- end }}
{{- end }}
{{- with .Values.proxy.service.port.open }}
- name: open
port: {{ .port }}
targetPort: {{ .targetPort }}
{{- if (and (eq $serviceType "NodePort") (not (empty .nodePort))) }}
nodePort: {{ .nodePort }}
{{- end }}
{{- end }}
{{- if eq .Values.proxy.service.type "LoadBalancer" }}
{{- if .Values.proxyserviceloadBalancerIP }}
loadBalancerIP: {{ .Values.proxyserviceloadBalancerIP }}
{{- end -}}
{{- if .Values.proxy.service.loadBalancerSourceRanges }}
loadBalancerSourceRanges:
{{- range .Values.proxy.service.loadBalancerSourceRanges }}
- {{ . }}
{{- end }}
{{- end -}}
{{- end -}}
# RBAC config for tiller. We grant cluster-admin to tiller so it can manage
# all namespaces. For a new cluster, kubectl apply this after installing
# tiller.
apiVersion: v1
kind: ServiceAccount
metadata:
name: tiller
namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: tiller
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-admin
subjects:
- kind: ServiceAccount
name: tiller
namespace: kube-system
# Copyright (c) 2018-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree. An additional grant
# of patent rights can be found in the PATENTS file in the same directory.
## Global values for NMS chart
nms:
magmalte:
manifests:
secrets: true
deployment: true
service: true
rbac: true
image:
repository: fjvicens/magmalte
tag: latest
nginx:
manifests:
configmap: true
secrets: true
deployment: true
service: true
rbac: true
# Reference to one or more secrets to be used when pulling images
# ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/
imagePullSecrets: []
# - name: orc8r-secrets-registry
## metrics subchart configuration.
metrics:
metrics:
create: true
prometheus:
create: true
prometheusCache:
create: true
alertmanager:
create: false
configmanager:
create: true
# secrets subchart configuration.
secrets:
create: true
# Define which secrets should be mounted by pods.
secret:
certs: orc8r-secrets-certs
configs:
orc8r: orc8r-secrets-configs-orc8r
envdir: orc8r-secrets-envdir
proxyserviceloadBalancerIP: ""
nginxserviceloadBalancerIP: ""
proxy:
# Service configuration.
service:
name: bootstrapper-orc8r-proxy
annotations: {}
labels: {}
type: LoadBalancer
port:
clientcert:
port: 9443
targetPort: 9443
nodePort: ""
open:
port: 9444
targetPort: 9444
nodePort: ""
loadBalancerIP: ""
loadBalancerSourceRanges: []
# proxy image
image:
repository: fjvicens/orc8r_proxy
tag: latest
pullPolicy: IfNotPresent
# Settings affecting proxy application
spec:
# magma controller domain name
hostname: "controller.magma.test"
http_proxy_backend: "orc8r-controller"
#http_proxy_hostname: ""
#http_proxy_docker_hostname: ""
#http_proxy_github_hostname: ""
# Number of proxy replicas desired
replicas: 1
# Resource limits & requestss
resources: {}
# limits:
# cpu: 100m
# memory: 128Mi
# requests:
# cpu: 100m
# memory: 128Mi
# Define which Nodes the Pods are scheduled on.
# ref: https://kubernetes.io/docs/user-guide/node-selection/
nodeSelector: {}
# Tolerations for use with node taints
# ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/
tolerations: []
# Assign proxy to run on specific nodes
# ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/
affinity: {}
controller:
# Service configuration.
service:
annotations: {}
labels: {}
type: ClusterIP
port: 8080
targetPort: 8080
# port range exposed by controller
portStart: 9079
portEnd: 9108
# controller image
image:
repository: fjvicens/orc8r_controller
tag: latest
pullPolicy: IfNotPresent
spec:
# Postgres/mysql configuration
database:
driver: postgres # mysql/postgres
sql_dialect: psql # maria/psql
db: magma # DB Name
protocol: tcp
host: postgresql
port: 5432
user: postgres
pass: postgres
migration:
new_handlers: 0
new_mconfigs: 0
mconfig_whitelist: ""
# Number of controller replicas desired
replicas: 1
# Resource limits & requests
resources: {}
# limits:
# cpu: 100m
# memory: 128Mi
# requests:
# cpu: 100m
# memory: 128Mi
# Define which Nodes the Pods are scheduled on.
# ref: https://kubernetes.io/docs/user-guide/node-selection/
nodeSelector: {}
# Tolerations for use with node taints
# ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/
tolerations: []
# Assign proxy to run on specific nodes
# ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/
affinity: {}
# Set True to create a CloudWatch agent to monitor metrics
cloudwatch:
create: false
mariadb:
create: true
postgresql:
create: true
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment