azure-container-networking/npm/azure-npm.yaml

178 строки
4.2 KiB
YAML
Исходник Обычный вид История

apiVersion: v1
kind: ServiceAccount
metadata:
name: azure-npm
namespace: kube-system
labels:
addonmanager.kubernetes.io/mode: EnsureExists
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: azure-npm
namespace: kube-system
labels:
addonmanager.kubernetes.io/mode: EnsureExists
rules:
- apiGroups:
- ""
resources:
- pods
- nodes
- namespaces
verbs:
- get
- list
- watch
- apiGroups:
- networking.k8s.io
resources:
- networkpolicies
verbs:
- get
- list
- watch
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: azure-npm-binding
namespace: kube-system
labels:
addonmanager.kubernetes.io/mode: EnsureExists
subjects:
- kind: ServiceAccount
name: azure-npm
namespace: kube-system
roleRef:
kind: ClusterRole
name: azure-npm
apiGroup: rbac.authorization.k8s.io
---
Prometheus metrics (#590) * prometheus additions to testmain (commented out right now) * home of the npm prometheus metrics and tools for updating them, testing them * add/remove policy metrics * add/remove iptables rule metric measurements * add/remove ipset metric measurements * testing for gauges. want to soon remove the boolean for including prometheus in unit testing * run http server that exposes prometheus from main * cleaner test additions with less code * removed incorrect instance of AddSet in the TestDeleteSet test * added prometheus annotations to pod templates * deleted unused file * much more organized initialization of metrics now. now includes map from metric to metric name * add ability to get summary count value. now getting gauge values and this new count value are done by passing the metric itself as a param instead of a string * condenses prometheus testing code base by condensing all prometheus error messages into a function * added testing for summary counts, condensed prometheus error handling code, and updated calls to use new form for getting metric values * update based on variable spelling change in metrics package * Added comments for functions and moved http handler code to the http file * fixed problem of registering same metric name for different metrics, and passing in the wrong param type for testing * made prometheus testing folder with interactive testing file. moved old random metric flux testing function over from ipsm_test * moved testing around again * fixed spelling mistake * counting mistake in unit test * handler variable ws in wrong file. Changed stdout printing to logging * fixed parameter errors and counting error in a test * moved utilities for testing prometheus metrics to npm/util. Updated StartHTTP to have an additional parameter for waiting after starting the server * updated uses of StartHTTP to have the extra parameter * updated GetValue and GetCountValue uses to use the prometheus features of the util package, which is now moved to a promutil package within npm/metrics/ * removed unnecessary comments, removed print statement, and added quantiles to all summary metrics * fixed problem of double registering metrics * wait longer for http server to start * moved tool in test-util.go to promutil/util.go * fixed timer to be in milliseconds and updated metric descriptions to mention units * removed unnecessary comments * http server always started in a go routine now. Added comment justifying the use of an http server * debugging http connection refused in pipeline * fixed syntax error * removed debugging wrapper around http service * sleep so that the testing metrics endpoint can be pinged * redesigned GetValue and GetCountValue so that they don't use http calls * removed random but helpful testing file - will write about quick testing in a wiki page * milliseconds were being truncated. now they have decimals * use direct Prometheus metric commands instead of wrapping them * removed code used when testing was done through http server. Moved registering to metric creation functions * added createGaugeVec, updated comments, made all help strings constants * added metric that counts number of entries in each ipset. still need to add tests * fixed creation of GaugeVecs, and use explicit labeling instead of order-based labeling now * updated GetVecValue method signature * added set to metrics on creation and wrote unit tests for CreateSet, AddToSet, DeleteFromSet, DeleteSet * use custom registry to limit content that Container Insights scrapes. Also log the start of http server * wrote TODO item comments for Restore and Destroy (currently these functions are only used in testing) * NPM won't crash if a Prometheus metric fails to register now (unlikely). Added logging for metric registration/creation, and explicit public function to initialize metrics so that we can finish log config first * initialize metrics in unit tests * renamed util.go to test-util.go Co-authored-by: Hunter Gregory <t-hugreg@microsoft.com>
2020-07-15 02:41:02 +03:00
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: azure-npm
namespace: kube-system
labels:
app: azure-npm
addonmanager.kubernetes.io/mode: EnsureExists
spec:
selector:
matchLabels:
k8s-app: azure-npm
template:
metadata:
labels:
k8s-app: azure-npm
annotations:
scheduler.alpha.kubernetes.io/critical-pod: ""
azure.npm/scrapeable: ""
spec:
priorityClassName: system-node-critical
tolerations:
- operator: "Exists"
effect: NoExecute
- operator: "Exists"
effect: NoSchedule
- key: CriticalAddonsOnly
operator: Exists
containers:
- name: azure-npm
image: mcr.microsoft.com/containernetworking/azure-npm:v1.4.45.3
2021-04-09 21:14:52 +03:00
resources:
limits:
cpu: 250m
memory: 300Mi
requests:
cpu: 250m
securityContext:
privileged: false
capabilities:
add:
- NET_ADMIN
readOnlyRootFilesystem: true
env:
- name: HOSTNAME
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: spec.nodeName
- name: NPM_CONFIG
value: /etc/azure-npm/azure-npm.json
volumeMounts:
- name: log
mountPath: /var/log
- name: xtables-lock
mountPath: /run/xtables.lock
- name: protocols
mountPath: /etc/protocols
- name: azure-npm-config
mountPath: /etc/azure-npm
- name: tmp
mountPath: /tmp
hostNetwork: true
hostUsers: false
nodeSelector:
kubernetes.io/os: linux
volumes:
- name: log
hostPath:
path: /var/log
type: Directory
- name: xtables-lock
hostPath:
path: /run/xtables.lock
type: File
- name: protocols
hostPath:
path: /etc/protocols
type: File
- name: azure-npm-config
configMap:
name: azure-npm-config
- name: tmp
emptyDir: {}
2019-09-25 21:32:29 +03:00
serviceAccountName: azure-npm
---
apiVersion: v1
kind: Service
metadata:
name: npm-metrics-cluster-service
namespace: kube-system
labels:
app: npm-metrics
spec:
selector:
k8s-app: azure-npm
ports:
- port: 9000
targetPort: 10091
---
apiVersion: v1
kind: ConfigMap
metadata:
name: azure-npm-config
namespace: kube-system
data:
azure-npm.json: |
{
"ResyncPeriodInMinutes": 15,
"ListeningPort": 10091,
"ListeningAddress": "0.0.0.0",
"ApplyIntervalInMilliseconds": 500,
"ApplyMaxBatches": 100,
"MaxBatchedACLsPerPod": 30,
"NetPolInvervalInMilliseconds": 500,
"MaxPendingNetPols": 100,
"Toggles": {
"EnablePrometheusMetrics": true,
"EnablePprof": true,
"EnableHTTPDebugAPI": true,
"EnableV2NPM": true,
perf: [NPM] [LINUX] add NetPols in background (#1969) * wip: apply dirty NetPols every 500ms in Linux * only build npm linux image * fix: check for empty cache * feat: toggle for netpol interval. default 500 ms * ci: remove stages "build binaries" and "run windows tests" * wip: max batched netpols (toggle-specified) * ci: remove manifest build/push for win npm * wip: handle ipset deletion properly and max batch for delete too * fix: correct remove policy * fix: only remove policy if it was in kernel * finalize toggles, allowing ability to turn off iptablesInBackground * ci: conf + cyc use PR's configmaps * fix: lints * fix dp toggle: iptablesInBackground * fix lock typo and config logging * fix background thread. add comments. only add tmp ref when enabled * copy pod selector list * fix: removepolicy needs namespace too * rename opInfo to event * fix: fix references and prevent concurrent map read/write * tmp: debug logging * fix: missing set references by swap keys and values * Revert "tmp: debug logging" This reverts commit 70ed34c714ea4a6d009a1fe90a7168be4bedd5bf. * fix: add podSelectorList to fake NetPol * log: do not print error when failing to delete non-existent nft rule * log: verbose iptables bootup * log: use fmt.Errorf for clean logging * log: never return error for iptables in background and fix some lints * fix: activate/deactivate azure chain rules * fix: correctly decrement netpols in kernel * ci: run UTs again * ci: update profiles. default to placefirst=false * address comment: rename batch to pendingPolicy * refactor: make dirty cache OS-specific * test: UTs * test: put UT cfg back to placefirst to not break things * ci: update cyclonus workflows * fmt: address comment & lint * fmt: rename numInKernel to policiesInKernel * log: switch to fmt.Errorf * fmt: whitespace * feat: resiliency to errors while reconciling dirty netpols * log: temporarily print everything for ipset restore * fix: remove nomatch from ipset -D for cidr blocks * test: UTs for non-happy path * test: fix hns fake * fix: don't change windows. let it delete ipsets when removing policies * fix windows lint * fix: ignore chain doesn't exist errors for iptables -D * feat: latency and failure metrics * test: update exit code for UT * metrics: new metrics should go in node-metrics path * style: simplify nesting * style: move identical windows & linux code to shared file * ci: remove v1 conformance and cyclonus * feat: add NetPols in background from the DP (revert background code in pMgr) * style: remove "background" from iptables metrics * revert changes in ipsetmanager, const.go, and dp.Remove/UpdatePolicy * style: whitespace * perf: use len() instead of creating slice from map * remove verbosity for iptables bootup * build: add return statement * style: whitespace * build: fix variable shadowing * build: fix more import shadowing * build: windows pointer issue and UT issue * test: fix UT for iptables error code 2 * ci: enable linux scale test * ci: revert to master pipeline.yaml * revert changes to chain-management. do changes in PR #2012 * log: change wording * test: UTs for netpol in background * log: wording * feat: apply ipsets for each netpol individually * config: rearrange ConfigMap & update capz yaml * fix: windows bootup phase logic for addpolicy * feat: restrict netpol in background to linux + nftables * test: skip nftables check for UT * style: netpols[0] instead of loop * log: address log comments * style: lint for long line --------- Co-authored-by: Vamsi Kalapala <vakr@microsoft.com>
2023-07-19 19:13:52 +03:00
"PlaceAzureChainFirst": false,
"ApplyInBackground": true,
"NetPolInBackground": true
}
}