This commit is contained in:
jprdonnelly
2019-09-25 13:50:02 -04:00
2 changed files with 176 additions and 105 deletions

18
Vagrantfile vendored
View File

@@ -10,6 +10,14 @@ servers = [
:mem => "3200", :mem => "3200",
:cpu => "2" :cpu => "2"
}, },
{
:name => "k8s-nfs",
:type => "nfs",
:box => "jprdonnelly/ubuntu-1804",
:eth1 => "192.168.205.14",
:mem => "2176",
:cpu => "2"
},
{ {
:name => "k8s-node1", :name => "k8s-node1",
:type => "node", :type => "node",
@@ -26,14 +34,6 @@ servers = [
:mem => "4224", :mem => "4224",
:cpu => "2", :cpu => "2",
}, },
{
:name => "k8s-nfs",
:type => "nfs",
:box => "jprdonnelly/ubuntu-1804",
:eth1 => "192.168.205.14",
:mem => "2176",
:cpu => "2"
},
# Uncomment section below to enable a 3rd worker node. # Uncomment section below to enable a 3rd worker node.
# { # {
# :name => "k8s-node3", # :name => "k8s-node3",
@@ -173,7 +173,7 @@ $configureNode = <<-SCRIPT
echo "This is a worker node" echo "This is a worker node"
sshpass -p "vagrant" scp -o StrictHostKeyChecking=no vagrant@192.168.205.10:/etc/kubeadm_join_cmd.sh . sshpass -p "vagrant" scp -o StrictHostKeyChecking=no vagrant@192.168.205.10:/etc/kubeadm_join_cmd.sh .
sudo sh ./kubeadm_join_cmd.sh sudo sh ./kubeadm_join_cmd.sh
# kubectl taint nodes k8s-nfs key=value:NoSchedule kubectl taint nodes k8s-nfs key=value:NoSchedule
SCRIPT SCRIPT
$configureNFS = <<-SCRIPT $configureNFS = <<-SCRIPT

View File

@@ -1,128 +1,190 @@
apiVersion: v1 apiVersion: v1
kind: Namespace kind: Namespace
metadata: metadata:
labels:
app: metallb
name: metallb-system name: metallb-system
---
apiVersion: policy/v1beta1
kind: PodSecurityPolicy
metadata:
labels: labels:
app: metallb app: metallb
---
apiVersion: v1
kind: ServiceAccount
metadata:
namespace: metallb-system
name: controller
labels:
app: metallb
---
apiVersion: v1
kind: ServiceAccount
metadata:
namespace: metallb-system
name: speaker name: speaker
namespace: metallb-system
spec:
allowPrivilegeEscalation: false
allowedCapabilities:
- NET_ADMIN
- NET_RAW
- SYS_ADMIN
fsGroup:
rule: RunAsAny
hostNetwork: true
hostPorts:
- max: 7472
min: 7472
privileged: true
runAsUser:
rule: RunAsAny
seLinux:
rule: RunAsAny
supplementalGroups:
rule: RunAsAny
volumes:
- '*'
---
apiVersion: v1
kind: ServiceAccount
metadata:
labels: labels:
app: metallb app: metallb
name: controller
namespace: metallb-system
---
apiVersion: v1
kind: ServiceAccount
metadata:
labels:
app: metallb
name: speaker
namespace: metallb-system
--- ---
apiVersion: rbac.authorization.k8s.io/v1 apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole kind: ClusterRole
metadata: metadata:
labels:
app: metallb
name: metallb-system:controller name: metallb-system:controller
labels:
app: metallb
rules: rules:
- apiGroups: [""] - apiGroups:
resources: ["services"] - ''
verbs: ["get", "list", "watch", "update"] resources:
- apiGroups: [""] - services
resources: ["services/status"] verbs:
verbs: ["update"] - get
- apiGroups: [""] - list
resources: ["events"] - watch
verbs: ["create", "patch"] - update
- apiGroups:
- ''
resources:
- services/status
verbs:
- update
- apiGroups:
- ''
resources:
- events
verbs:
- create
- patch
--- ---
apiVersion: rbac.authorization.k8s.io/v1 apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole kind: ClusterRole
metadata: metadata:
name: metallb-system:speaker
labels: labels:
app: metallb app: metallb
name: metallb-system:speaker
rules: rules:
- apiGroups: [""] - apiGroups:
resources: ["services", "endpoints", "nodes"] - ''
verbs: ["get", "list", "watch"] resources:
- services
- endpoints
- nodes
verbs:
- get
- list
- watch
- apiGroups:
- ''
resources:
- events
verbs:
- create
- patch
- apiGroups:
- extensions
resourceNames:
- speaker
resources:
- podsecuritypolicies
verbs:
- use
--- ---
apiVersion: rbac.authorization.k8s.io/v1 apiVersion: rbac.authorization.k8s.io/v1
kind: Role kind: Role
metadata: metadata:
namespace: metallb-system
name: config-watcher
labels: labels:
app: metallb app: metallb
name: config-watcher
namespace: metallb-system
rules: rules:
- apiGroups: [""] - apiGroups:
resources: ["configmaps"] - ''
verbs: ["get", "list", "watch"] resources:
- apiGroups: [""] - configmaps
resources: ["events"] verbs:
verbs: ["create"] - get
- list
- watch
--- ---
## Role bindings
apiVersion: rbac.authorization.k8s.io/v1 apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding kind: ClusterRoleBinding
metadata: metadata:
name: metallb-system:controller
labels: labels:
app: metallb app: metallb
name: metallb-system:controller
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: metallb-system:controller
subjects: subjects:
- kind: ServiceAccount - kind: ServiceAccount
name: controller name: controller
namespace: metallb-system namespace: metallb-system
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: metallb-system:controller
--- ---
apiVersion: rbac.authorization.k8s.io/v1 apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding kind: ClusterRoleBinding
metadata: metadata:
name: metallb-system:speaker
labels: labels:
app: metallb app: metallb
subjects: name: metallb-system:speaker
- kind: ServiceAccount
name: speaker
namespace: metallb-system
roleRef: roleRef:
apiGroup: rbac.authorization.k8s.io apiGroup: rbac.authorization.k8s.io
kind: ClusterRole kind: ClusterRole
name: metallb-system:speaker name: metallb-system:speaker
subjects:
- kind: ServiceAccount
name: speaker
namespace: metallb-system
--- ---
apiVersion: rbac.authorization.k8s.io/v1 apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding kind: RoleBinding
metadata: metadata:
namespace: metallb-system
name: config-watcher
labels: labels:
app: metallb app: metallb
name: config-watcher
namespace: metallb-system
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: config-watcher
subjects: subjects:
- kind: ServiceAccount - kind: ServiceAccount
name: controller name: controller
- kind: ServiceAccount - kind: ServiceAccount
name: speaker name: speaker
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: config-watcher
--- ---
apiVersion: apps/v1beta2 apiVersion: apps/v1
kind: DaemonSet kind: DaemonSet
metadata: metadata:
namespace: metallb-system
name: speaker
labels: labels:
app: metallb app: metallb
component: speaker component: speaker
name: speaker
namespace: metallb-system
spec: spec:
selector: selector:
matchLabels: matchLabels:
@@ -130,21 +192,15 @@ spec:
component: speaker component: speaker
template: template:
metadata: metadata:
annotations:
prometheus.io/port: '7472'
prometheus.io/scrape: 'true'
labels: labels:
app: metallb app: metallb
component: speaker component: speaker
annotations:
prometheus.io/scrape: "true"
prometheus.io/port: "7472"
spec: spec:
serviceAccountName: speaker
terminationGracePeriodSeconds: 0
hostNetwork: true
containers: containers:
- name: speaker - args:
image: metallb/speaker:v0.7.3
imagePullPolicy: IfNotPresent
args:
- --port=7472 - --port=7472
- --config=config - --config=config
env: env:
@@ -152,32 +208,47 @@ spec:
valueFrom: valueFrom:
fieldRef: fieldRef:
fieldPath: spec.nodeName fieldPath: spec.nodeName
- name: METALLB_HOST
valueFrom:
fieldRef:
fieldPath: status.hostIP
image: metallb/speaker:v0.8.1
imagePullPolicy: IfNotPresent
name: speaker
ports: ports:
- name: monitoring - containerPort: 7472
containerPort: 7472 name: monitoring
resources: resources:
limits: limits:
cpu: 100m cpu: 100m
memory: 100Mi memory: 100Mi
securityContext: securityContext:
allowPrivilegeEscalation: false allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
capabilities: capabilities:
drop:
- all
add: add:
- net_raw - NET_ADMIN
- NET_RAW
- SYS_ADMIN
drop:
- ALL
readOnlyRootFilesystem: true
hostNetwork: true
nodeSelector:
beta.kubernetes.io/os: linux
serviceAccountName: speaker
terminationGracePeriodSeconds: 0
tolerations:
- effect: NoSchedule
key: node-role.kubernetes.io/master
--- ---
apiVersion: apps/v1beta2 apiVersion: apps/v1
kind: Deployment kind: Deployment
metadata: metadata:
namespace: metallb-system
name: controller
labels: labels:
app: metallb app: metallb
component: controller component: controller
name: controller
namespace: metallb-system
spec: spec:
revisionHistoryLimit: 3 revisionHistoryLimit: 3
selector: selector:
@@ -186,37 +257,37 @@ spec:
component: controller component: controller
template: template:
metadata: metadata:
annotations:
prometheus.io/port: '7472'
prometheus.io/scrape: 'true'
labels: labels:
app: metallb app: metallb
component: controller component: controller
annotations:
prometheus.io/scrape: "true"
prometheus.io/port: "7472"
spec: spec:
serviceAccountName: controller
terminationGracePeriodSeconds: 0
securityContext:
runAsNonRoot: true
runAsUser: 65534 # nobody
containers: containers:
- name: controller - args:
image: metallb/controller:v0.7.3
imagePullPolicy: IfNotPresent
args:
- --port=7472 - --port=7472
- --config=config - --config=config
image: metallb/controller:v0.8.1
imagePullPolicy: IfNotPresent
name: controller
ports: ports:
- name: monitoring - containerPort: 7472
containerPort: 7472 name: monitoring
resources: resources:
limits: limits:
cpu: 100m cpu: 100m
memory: 100Mi memory: 100Mi
securityContext: securityContext:
allowPrivilegeEscalation: false allowPrivilegeEscalation: false
capabilities: capabilities:
drop: drop:
- all - all
readOnlyRootFilesystem: true readOnlyRootFilesystem: true
nodeSelector:
beta.kubernetes.io/os: linux
securityContext:
runAsNonRoot: true
runAsUser: 65534
serviceAccountName: controller
terminationGracePeriodSeconds: 0