Skip to content

Commit

Permalink
feat(kubectl): add manifests for kubectl install
Browse files Browse the repository at this point in the history
  - adding example manifests files for kubectl apply
  - resolves #188

Signed-off-by: Anton Ouzounov <aouzounov@vmware.com>
  • Loading branch information
Anton Ouzounov committed Apr 6, 2021
1 parent 3dda3bd commit 339e594
Show file tree
Hide file tree
Showing 4 changed files with 263 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type manager interface {

// CheckAndInstallCRDs checks whether the CRD is already defined in the cluster
// and, if not, install it and waits for it to be available
// It will automatically install either the legacy v1beta1 CRD or the neq v1 CRD
// It will automatically install either the legacy v1beta1 CRD or the new v1 CRD
// based on the available APIs in the Kubernetes cluster
func CheckAndInstallCRD(config *rest.Config) error {
clientset, err := clientset.NewForConfig(config)
Expand Down
22 changes: 22 additions & 0 deletions kubectl/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
### Installing log-router manually with kubectl:

We support installing log-router (KFO) with Helm 3. However, in cases where that is not possible or not preferred, these instructions should suffice in getting started with log-router in a k8s cluster. You are responsible for figuring out which [flags](https://github.com/vmware/kube-fluentd-operator#synopsis) and environment variables need to be set on the log-router containers for your particular environment.

#### Install the CRD:
```bash
kubectl apply -f ./crd.yaml
```


#### Install the other kubectl manifests:

```bash
# Get the latest tag from github via curl:
export kube_latest_tag=$(curl --silent "https://api.github.com/repos/vmware/kube-fluentd-operator/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')

# Inject the latest tag into the manifests:
sed -i .bak -e "s|<INSERT_TAG_HERE>|${kube_latest_tag}|g" manifests.yaml

# Install with kubectl:
kubectl apply -f ./manifests.yaml
```
28 changes: 28 additions & 0 deletions kubectl/crd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# log-router CRD resource:
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: fluentdconfigs.logs.vdp.vmware.com
spec:
conversion:
strategy: None
group: logs.vdp.vmware.com
names:
kind: FluentdConfig
listKind: FluentdConfigList
plural: fluentdconfigs
singular: fluentdconfig
scope: Namespaced
versions:
- name: v1beta1
schema:
openAPIV3Schema:
properties:
spec:
properties:
fluentconf:
type: string
type: object
type: object
served: true
storage: true
212 changes: 212 additions & 0 deletions kubectl/manifests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,212 @@
---
# Source: log-router/templates/sa.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
labels:
app: log-router
release: log-router
name: log-router-log-router
---
# Source: log-router/templates/clusterrole.yaml
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRole
metadata:
labels:
app: log-router
release: log-router
name: log-router-log-router
rules:
- apiGroups: [""]
resources:
- configmaps
- namespaces
- pods
verbs:
- get
- list
- watch
- apiGroups: [""]
resources:
- namespaces
verbs:
- patch
- apiGroups: ["apiextensions.k8s.io"]
resources:
- customresourcedefinitions
verbs:
- create
- get
- watch
- list
- apiGroups: ["logs.vdp.vmware.com"]
resources:
- fluentdconfigs
verbs:
- get
- list
- watch
---
# Source: log-router/templates/rolebinding.yaml
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
labels:
app: log-router
release: log-router
name: log-router-log-router
subjects:
- kind: ServiceAccount
name: log-router-log-router
namespace: infra-system
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: log-router-log-router
---
# Source: log-router/templates/service.yaml
apiVersion: v1
kind: Service
metadata:
labels:
app: log-router
release: log-router
metrics: fluentd
annotations:
prometheus.io/scrape: "true"
prometheus.io/port: "24231"
name: log-router-log-router
spec:
selector:
app: log-router
release: log-router
ports:
- port: 24231
name: prometheus
targetPort: prometheus
---
# Source: log-router/templates/service.yaml
apiVersion: v1
kind: Service
metadata:
labels:
app: log-router
release: log-router
metrics: reloader
annotations:
prometheus.io/scrape: "true"
prometheus.io/port: "9000"
name: log-router-log-router-reloader
spec:
selector:
app: log-router
release: log-router
ports:
- port: 9000
name: metrics
targetPort: metrics
---
# Source: log-router/templates/daemonset.yaml
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: log-router-log-router
labels:
app: log-router
chart: log-router-0.3.6
release: log-router
heritage: Helm
spec:
selector:
matchLabels:
app: log-router
release: log-router
template:
metadata:
labels:
app: log-router
release: log-router
spec:
serviceAccountName: log-router-log-router
securityContext:
fsGroup: 0
runAsGroup: 0
runAsUser: 0
containers:
- name: fluentd
image: "vmware/kube-fluentd-operator:<INSERT_TAG_HERE>"
env:
- name: K8S_NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
imagePullPolicy: IfNotPresent
ports:
- name: prometheus
containerPort: 24231
volumeMounts:
- name: fluentconf
mountPath: /fluentd/etc
- name: varlog
mountPath: /var/log
- name: kubeletroot
mountPath: "/var/lib/kubelet"
readOnly: true
- name: varlibdockercontainers
mountPath: /var/lib/docker/containers
readOnly: true
- mountPath: /var/ossec
name: ossec
readOnly: true
resources:
limits:
memory: 2048Mi
requests:
memory: 2048Mi
- name: reloader
image: "vmware/kube-fluentd-operator:<INSERT_TAG_HERE>"
imagePullPolicy: IfNotPresent
ports:
- name: metrics
containerPort: 9000
command:
- /bin/config-reloader
- --datasource=crd
- --default-configmap=fluentd-config
- --interval=90
- --log-level=info
- --output-dir=/fluentd/etc
- --templates-dir=/templates
- --id=log-router-log-router
- --fluentd-binary
- /usr/local/bundle/bin/fluentd -p /fluentd/plugins --log-rotate-age 5 --log-rotate-size 1048576000
- --kubelet-root
- "/var/lib/kubelet"
- --prometheus-enabled
- --metrics-port=9000
- --admin-namespace=kube-system
volumeMounts:
- name: fluentconf
mountPath: /fluentd/etc
resources:
limits:
memory: 1Gi
requests:
memory: 512Mi
tolerations:
- effect: NoSchedule
key: node-role.kubernetes.io/master
volumes:
- name: fluentconf
emptyDir: {}
- name: kubeletroot
hostPath:
path: "/var/lib/kubelet"
- name: varlog
hostPath:
path: /var/log
- name: varlibdockercontainers
hostPath:
path: /var/lib/docker/containers
updateStrategy:
type: RollingUpdate

0 comments on commit 339e594

Please sign in to comment.