Skip to content

Commit

Permalink
Merge pull request #3391 from ivans3/logviewer-addon-pr7
Browse files Browse the repository at this point in the history
Initial commit of logviewer addon
  • Loading branch information
tstromberg authored Jan 25, 2019
2 parents ad2b762 + ed7031c commit b61207c
Show file tree
Hide file tree
Showing 6 changed files with 140 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cmd/minikube/cmd/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,11 @@ var settings = []Setting{
callbacks: []setFn{EnableOrDisableAddon},
},
{
name: "logviewer",
set: SetBool,
validations: []setFn{IsValidAddon},
},
{
name: "gvisor",
set: SetBool,
validations: []setFn{IsValidAddon, IsContainerdRuntime},
Expand Down
78 changes: 78 additions & 0 deletions deploy/addons/logviewer/logviewer-dp-and-svc.yaml
Original file line number Diff line number Diff line change
@@ -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/
43 changes: 43 additions & 0 deletions deploy/addons/logviewer/logviewer-rbac.yaml
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions docs/addons.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,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)
* [storage-provisioner-gluster](../deploy/addons/storage-provisioner-gluster/README.md)

Expand Down
1 change: 1 addition & 0 deletions docs/contributors/adding_an_addon.md
Original file line number Diff line number Diff line change
Expand Up @@ -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: <NEW_ADDON_NAME>` 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 <NEW_ADDON_NAME>` work properly, the `kubernetes.io/minikube-addons-endpoint: <NEW_ADDON_NAME>` 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:
Expand Down
12 changes: 12 additions & 0 deletions pkg/minikube/assets/addons.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,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",
Expand Down

0 comments on commit b61207c

Please sign in to comment.