diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c93932d --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.vagrant +*.crt diff --git a/.yamllint.yaml b/.yamllint.yaml new file mode 100644 index 0000000..14d3740 --- /dev/null +++ b/.yamllint.yaml @@ -0,0 +1,12 @@ +--- +extends: default + +rules: + indentation: + spaces: 2 + indent-sequences: true + check-multi-line-strings: false + brackets: + forbid: true + line-length: + max: 120 diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..f06407c --- /dev/null +++ b/Makefile @@ -0,0 +1,2 @@ +lint-yaml: + find . -type f -name '*.yaml' | xargs yamllint diff --git a/Vagrantfile b/Vagrantfile old mode 100755 new mode 100644 index a621081..642cd7a --- a/Vagrantfile +++ b/Vagrantfile @@ -13,6 +13,14 @@ env = YAML.load_file('environment.yaml') # Limitando apenas a ultima versao estavel do Vagrant instalada Vagrant.require_version '>= 2.0.0' +SCRIPT = <<-EOF +echo 'unattended-upgrades unattended-upgrades/enable_auto_updates boolean false' | sudo debconf-set-selections +apt-get update +apt-get upgrade -y +apt-get autoremove -y +dpkg-reconfigure -f noninteractive unattended-upgrades +EOF + Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| # Iteracao com os servidores do ambiente env.each do |env| @@ -20,15 +28,25 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| srv.vm.box = env['box'] srv.vm.hostname = env['hostname'] srv.vm.network 'private_network', ip: env['ipaddress'] + if env['additional_interface'] == true srv.vm.network 'private_network', ip: '1.0.0.100', auto_config: false end + + srv.vbguest.auto_update = true + srv.vm.provider 'virtualbox' do |vb| vb.name = env['name'] vb.memory = env['memory'] vb.cpus = env['cpus'] + vb.linked_clone = true end + + srv.vm.provision 'shell', + inline: SCRIPT, + env: {DEBIAN_FRONTEND: 'noninteractive'} + srv.vm.provision 'ansible_local' do |ansible| ansible.playbook = env['provision'] ansible.install_mode = 'pip' diff --git a/aula04/rbac/analista-rbac.yaml b/aula04/rbac/analista-rbac.yaml new file mode 100644 index 0000000..47a82a3 --- /dev/null +++ b/aula04/rbac/analista-rbac.yaml @@ -0,0 +1,110 @@ +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: namespace-lister +rules: + - apiGroups: + - "" + resources: + - namespaces + verbs: + - list + - get +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: namespace-lister +subjects: + - kind: User + name: analista + apiGroup: rbac.authorization.k8s.io +roleRef: + kind: ClusterRole + name: namespace-lister + apiGroup: rbac.authorization.k8s.io +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: + name: analista + namespace: 4labs +rules: + - apiGroups: + - "" + resources: + - pods + - services + - services/proxy + - configmaps + - secrets + - replicationcontrollers + - events + - pods/portforward + - pods/exec + - pods/log + - endpoints + - persistentvolumeclaims + verbs: + - get + - list + - create + - update + - patch + - delete + - watch + - apiGroups: + - apps + resources: + - deployments + - deployments/scale + - replicasets + - daemonsets + - statefulsets + verbs: + - get + - list + - create + - update + - patch + - delete + - watch + - apiGroups: + - autoscaling + resources: + - horizontalpodautoscalers + verbs: + - get + - list + - create + - update + - patch + - delete + - watch + - apiGroups: + - batch + resources: + - jobs + - cronjobs + verbs: + - get + - list + - create + - update + - patch + - delete + - watch + - apiGroups: + - networking.k8s.io + resources: + - ingresses + - networkpolicies + verbs: + - get + - list + - create + - update + - patch + - delete + - watch diff --git a/environment.yaml b/environment.yaml old mode 100755 new mode 100644 index 4eef084..85cbdfd --- a/environment.yaml +++ b/environment.yaml @@ -1,4 +1,12 @@ --- +- name: kube-infra + box: devopsbox/ubuntu-20.04 + hostname: kube-infra + ipaddress: 172.16.1.103 + memory: 512 + cpus: 1 + provision: provision/ansible/kube-infra.yaml + - name: kube-master box: devopsbox/ubuntu-20.04 hostname: kube-master @@ -22,11 +30,3 @@ memory: 2560 cpus: 2 provision: provision/ansible/kube-node2.yaml - -- name: kube-infra - box: devopsbox/ubuntu-20.04 - hostname: kube-infra - ipaddress: 172.16.1.103 - memory: 512 - cpus: 1 - provision: provision/ansible/kube-infra.yaml