Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial commit of logviewer addon #3391

Merged
merged 2 commits into from
Jan 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions cmd/minikube/cmd/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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},
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 @@ -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.
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 @@ -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",
Expand Down