diff --git a/cmd/minikube/cmd/config/config.go b/cmd/minikube/cmd/config/config.go index effe390dec36..cd49e78de5ba 100644 --- a/cmd/minikube/cmd/config/config.go +++ b/cmd/minikube/cmd/config/config.go @@ -213,6 +213,11 @@ var settings = []Setting{ callbacks: []setFn{EnableOrDisableAddon}, }, { + name: "logviewer", + set: SetBool, + validations: []setFn{IsValidAddon}, + }, + { name: "gvisor", set: SetBool, validations: []setFn{IsValidAddon, IsContainerdRuntime}, diff --git a/deploy/addons/logviewer/logviewer-dp-and-svc.yaml b/deploy/addons/logviewer/logviewer-dp-and-svc.yaml new file mode 100644 index 000000000000..5ebab8e63568 --- /dev/null +++ b/deploy/addons/logviewer/logviewer-dp-and-svc.yaml @@ -0,0 +1,78 @@ +apiVersion: v1 +kind: Service +metadata: + name: logviewer + namespace: kube-system + labels: + kubernetes.io/minikube-addons: logviewer + kubernetes.io/minikube-addons-endpoint: logviewer + addonmanager.kubernetes.io/mode: Reconcile +spec: + ports: + - port: 3000 + name: http + nodePort: 32000 + selector: + app: logviewer + type: NodePort + +--- + +apiVersion: apps/v1 +kind: Deployment +metadata: + name: logviewer + namespace: kube-system + labels: + addonmanager.kubernetes.io/mode: Reconcile + kubernetes.io/minikube-addons: logviewer +spec: + replicas: 1 + selector: + matchLabels: + app: logviewer + addonmanager.kubernetes.io/mode: Reconcile + template: + metadata: + labels: + app: logviewer + addonmanager.kubernetes.io/mode: Reconcile + spec: + serviceAccountName: sa-logviewer + containers: + - name: logviewer + imagePullPolicy: Always + image: docker.io/ivans3/minikube-log-viewer:latest + volumeMounts: + - name: logs + mountPath: /var/log/containers/ + - name: logs-pods + mountPath: /var/log/pods + - name: logs-containers-mnt-sda1 + mountPath: /mnt/sda1/var/lib/docker/containers/ + - name: logs-containers + mountPath: /var/lib/docker/containers/ + ports: + - containerPort: 3000 + protocol: TCP + livenessProbe: + httpGet: + path: / + port: 3000 + initialDelaySeconds: 30 + timeoutSeconds: 30 + volumes: + - name: logs + hostPath: + path: /var/log/containers + - name: logs-pods + hostPath: + path: /var/log/pods + #for minikube v0.22.2: + - name: logs-containers-mnt-sda1 + hostPath: + path: /mnt/sda1/var/lib/docker/containers/ + #for minikube v0.22.3+: + - name: logs-containers + hostPath: + path: /var/lib/docker/containers/ diff --git a/deploy/addons/logviewer/logviewer-rbac.yaml b/deploy/addons/logviewer/logviewer-rbac.yaml new file mode 100644 index 000000000000..86fd9efd8ac2 --- /dev/null +++ b/deploy/addons/logviewer/logviewer-rbac.yaml @@ -0,0 +1,43 @@ + +apiVersion: v1 +kind: ServiceAccount +metadata: + name: sa-logviewer + namespace: kube-system + labels: + addonmanager.kubernetes.io/mode: Reconcile + kubernetes.io/minikube-addons: logviewer + +--- + +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + labels: + addonmanager.kubernetes.io/mode: Reconcile + kubernetes.io/minikube-addons: logviewer + name: cr-logviewer +rules: +- apiGroups: [""] + resources: ["namespaces"] + verbs: ["get", "watch", "list"] + +--- + +# This cluster role binding allows "sa-logviewer" to read namespace metadata +kind: ClusterRoleBinding +apiVersion: rbac.authorization.k8s.io/v1 +metadata: + name: crb-logviewer + namespace: kube-system + labels: + kubernetes.io/minikube-addons: logviewer + addonmanager.kubernetes.io/mode: Reconcile +subjects: +- kind: ServiceAccount + name: sa-logviewer + namespace: kube-system +roleRef: + kind: ClusterRole #this must be Role or ClusterRole + name: cr-logviewer # this must match the name of the Role or ClusterRole you wish to bind to + apiGroup: rbac.authorization.k8s.io diff --git a/docs/addons.md b/docs/addons.md index fdd22a88d61a..95c23d99cb92 100644 --- a/docs/addons.md +++ b/docs/addons.md @@ -36,6 +36,7 @@ The currently supported addons include: * [Freshpod](https://github.com/GoogleCloudPlatform/freshpod) * [nvidia-driver-installer](https://github.com/GoogleCloudPlatform/container-engine-accelerators/tree/master/nvidia-driver-installer/minikube) * [nvidia-gpu-device-plugin](https://github.com/GoogleCloudPlatform/container-engine-accelerators/tree/master/cmd/nvidia_gpu) +* [logviewer](https://github.com/ivans3/minikube-log-viewer) * [gvisor](../deploy/addons/gvisor/README.md) If you would like to have minikube properly start/restart custom addons, place the addon(s) you wish to be launched with minikube in the `.minikube/addons` directory. Addons in this folder will be moved to the minikube VM and launched each time minikube is started/restarted. diff --git a/docs/contributors/adding_an_addon.md b/docs/contributors/adding_an_addon.md index f5ec3ce9089f..0010e343248e 100644 --- a/docs/contributors/adding_an_addon.md +++ b/docs/contributors/adding_an_addon.md @@ -4,6 +4,7 @@ To add a new addon to minikube the following steps are required: * For the new addon's .yaml file(s): * Put the required .yaml files for the addon in the `minikube/deploy/addons` directory. * Add the `kubernetes.io/minikube-addons: ` label to each piece of the addon (ReplicationController, Service, etc.) + * Also, `addonmanager.kubernetes.io/mode` annotation is needed so that your resources are picked up by the `addon-manager` minikube addon. * In order to have `minikube addons open ` work properly, the `kubernetes.io/minikube-addons-endpoint: ` label must be added to the appropriate endpoint service (what the user would want to open/interact with). This service must be of type NodePort. * To add the addon into minikube commands/VM: diff --git a/pkg/minikube/assets/addons.go b/pkg/minikube/assets/addons.go index 825de3b8e5bd..ac132fde0f84 100644 --- a/pkg/minikube/assets/addons.go +++ b/pkg/minikube/assets/addons.go @@ -227,6 +227,18 @@ var Addons = map[string]*Addon{ "nvidia-gpu-device-plugin.yaml", "0640"), }, false, "nvidia-gpu-device-plugin"), + "logviewer": NewAddon([]*BinDataAsset{ + NewBinDataAsset( + "deploy/addons/logviewer/logviewer-dp-and-svc.yaml", + constants.AddonsPath, + "logviewer-dp-and-svc.yaml", + "0640"), + NewBinDataAsset( + "deploy/addons/logviewer/logviewer-rbac.yaml", + constants.AddonsPath, + "logviewer-rbac.yaml", + "0640"), + }, false, "logviewer"), "gvisor": NewAddon([]*BinDataAsset{ NewBinDataAsset( "deploy/addons/gvisor/gvisor-pod.yaml",