Browse Source
[calico] add calico apiserver (#8690)
[calico] add calico apiserver (#8690)
* [calico] add calico apiserver * fix yamllint * remove addext argument * Configure API server with the CA bundle * add check kddpull/8698/head
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 507 additions and 14 deletions
Split View
Diff Options
-
3inventory/sample/group_vars/k8s_cluster/k8s-net-calico.yml
-
13roles/download/defaults/main.yml
-
2roles/kubespray-defaults/defaults/main.yaml
-
3roles/network_plugin/calico/defaults/main.yml
-
60roles/network_plugin/calico/tasks/calico_apiserver_certs.yml
-
12roles/network_plugin/calico/tasks/check.yml
-
51roles/network_plugin/calico/tasks/install.yml
-
5roles/network_plugin/calico/tasks/typha_certs.yml
-
10roles/network_plugin/calico/templates/calico-apiserver-ns.yml.j2
-
320roles/network_plugin/calico/templates/calico-apiserver.yml.j2
-
4roles/network_plugin/calico/templates/calico-node.yml.j2
-
1roles/network_plugin/calico/templates/calico-typha.yml.j2
-
35roles/network_plugin/calico/templates/make-ssl-calico.sh.j2
-
1tests/files/packet_centos7-calico-ha-once-localhost.yml
-
1tests/files/packet_centos7-calico-ha.yml
@ -0,0 +1,60 @@ |
|||
--- |
|||
- name: Calico | Check if calico apiserver exists |
|||
command: "{{ kubectl }} -n calico-apiserver get secret calico-apiserver-certs" |
|||
register: calico_apiserver_secret |
|||
changed_when: false |
|||
failed_when: false |
|||
|
|||
- name: Calico | Create ns manifests |
|||
template: |
|||
src: "calico-apiserver-ns.yml.j2" |
|||
dest: "{{ kube_config_dir }}/calico-apiserver-ns.yml" |
|||
mode: 0644 |
|||
|
|||
- name: Calico | Apply ns manifests |
|||
kube: |
|||
kubectl: "{{ bin_dir }}/kubectl" |
|||
filename: "{{ kube_config_dir }}/calico-apiserver-ns.yml" |
|||
state: "latest" |
|||
|
|||
- name: Calico | Ensure calico certs dir |
|||
file: |
|||
path: /etc/calico/certs |
|||
state: directory |
|||
mode: 0755 |
|||
when: calico_apiserver_secret.rc != 0 |
|||
|
|||
- name: Calico | Copy ssl script for apiserver certs |
|||
template: |
|||
src: make-ssl-calico.sh.j2 |
|||
dest: "{{ bin_dir }}/make-ssl-apiserver.sh" |
|||
mode: 0755 |
|||
when: calico_apiserver_secret.rc != 0 |
|||
|
|||
- name: Calico | Copy ssl config for apiserver certs |
|||
copy: |
|||
src: openssl.conf |
|||
dest: /etc/calico/certs/openssl.conf |
|||
mode: 0644 |
|||
when: calico_apiserver_secret.rc != 0 |
|||
|
|||
- name: Calico | Generate apiserver certs |
|||
command: >- |
|||
{{ bin_dir }}/make-ssl-apiserver.sh |
|||
-f /etc/calico/certs/openssl.conf |
|||
-c {{ kube_cert_dir }} |
|||
-d /etc/calico/certs |
|||
-s apiserver |
|||
when: calico_apiserver_secret.rc != 0 |
|||
|
|||
- name: Calico | Create calico apiserver generic secrets |
|||
command: >- |
|||
{{ kubectl }} -n calico-apiserver |
|||
create secret generic {{ item.name }} |
|||
--from-file={{ item.cert }} |
|||
--from-file={{ item.key }} |
|||
with_items: |
|||
- name: calico-apiserver-certs |
|||
cert: /etc/calico/certs/apiserver.crt |
|||
key: /etc/calico/certs/apiserver.key |
|||
when: calico_apiserver_secret.rc != 0 |
@ -0,0 +1,10 @@ |
|||
# This is a tech-preview manifest which installs the Calico API server. Note that this manifest is liable to change |
|||
# or be removed in future releases without further warning. |
|||
# |
|||
# Namespace and namespace-scoped resources. |
|||
apiVersion: v1 |
|||
kind: Namespace |
|||
metadata: |
|||
labels: |
|||
name: calico-apiserver |
|||
name: calico-apiserver |
@ -0,0 +1,320 @@ |
|||
# Policy to ensure the API server isn't cut off. Can be modified, but ensure |
|||
# that the main API server is always able to reach the Calico API server. |
|||
kind: NetworkPolicy |
|||
apiVersion: networking.k8s.io/v1 |
|||
metadata: |
|||
name: allow-apiserver |
|||
namespace: calico-apiserver |
|||
spec: |
|||
podSelector: |
|||
matchLabels: |
|||
apiserver: "true" |
|||
ingress: |
|||
- ports: |
|||
- protocol: TCP |
|||
port: 5443 |
|||
|
|||
--- |
|||
|
|||
apiVersion: v1 |
|||
kind: Service |
|||
metadata: |
|||
name: calico-api |
|||
namespace: calico-apiserver |
|||
spec: |
|||
ports: |
|||
- name: apiserver |
|||
port: 443 |
|||
protocol: TCP |
|||
targetPort: 5443 |
|||
selector: |
|||
apiserver: "true" |
|||
type: ClusterIP |
|||
|
|||
--- |
|||
|
|||
apiVersion: apps/v1 |
|||
kind: Deployment |
|||
metadata: |
|||
labels: |
|||
apiserver: "true" |
|||
k8s-app: calico-apiserver |
|||
name: calico-apiserver |
|||
namespace: calico-apiserver |
|||
spec: |
|||
replicas: 1 |
|||
selector: |
|||
matchLabels: |
|||
apiserver: "true" |
|||
strategy: |
|||
type: Recreate |
|||
template: |
|||
metadata: |
|||
labels: |
|||
apiserver: "true" |
|||
k8s-app: calico-apiserver |
|||
name: calico-apiserver |
|||
namespace: calico-apiserver |
|||
spec: |
|||
containers: |
|||
- args: |
|||
- --secure-port=5443 |
|||
- -v=5 |
|||
env: |
|||
- name: DATASTORE_TYPE |
|||
value: kubernetes |
|||
image: {{ calico_apiserver_image_repo }}:{{ calico_apiserver_image_tag }} |
|||
imagePullPolicy: {{ k8s_image_pull_policy }} |
|||
livenessProbe: |
|||
httpGet: |
|||
path: /version |
|||
port: 5443 |
|||
scheme: HTTPS |
|||
initialDelaySeconds: 90 |
|||
periodSeconds: 10 |
|||
name: calico-apiserver |
|||
readinessProbe: |
|||
exec: |
|||
command: |
|||
- /code/filecheck |
|||
failureThreshold: 5 |
|||
initialDelaySeconds: 5 |
|||
periodSeconds: 10 |
|||
securityContext: |
|||
privileged: false |
|||
runAsUser: 0 |
|||
volumeMounts: |
|||
- mountPath: /code/apiserver.local.config/certificates |
|||
name: calico-apiserver-certs |
|||
dnsPolicy: ClusterFirst |
|||
nodeSelector: |
|||
kubernetes.io/os: linux |
|||
restartPolicy: Always |
|||
serviceAccount: calico-apiserver |
|||
serviceAccountName: calico-apiserver |
|||
tolerations: |
|||
- effect: NoSchedule |
|||
key: node-role.kubernetes.io/master |
|||
volumes: |
|||
- name: calico-apiserver-certs |
|||
secret: |
|||
secretName: calico-apiserver-certs |
|||
|
|||
--- |
|||
|
|||
apiVersion: v1 |
|||
kind: ServiceAccount |
|||
metadata: |
|||
name: calico-apiserver |
|||
namespace: calico-apiserver |
|||
|
|||
--- |
|||
|
|||
# Cluster-scoped resources below here. |
|||
apiVersion: apiregistration.k8s.io/v1 |
|||
kind: APIService |
|||
metadata: |
|||
name: v3.projectcalico.org |
|||
spec: |
|||
group: projectcalico.org |
|||
groupPriorityMinimum: 1500 |
|||
caBundle: {{ calico_apiserver_cabundle }} |
|||
service: |
|||
name: calico-api |
|||
namespace: calico-apiserver |
|||
port: 443 |
|||
version: v3 |
|||
versionPriority: 200 |
|||
|
|||
--- |
|||
|
|||
apiVersion: rbac.authorization.k8s.io/v1 |
|||
kind: ClusterRole |
|||
metadata: |
|||
name: calico-crds |
|||
rules: |
|||
- apiGroups: |
|||
- extensions |
|||
- networking.k8s.io |
|||
- "" |
|||
resources: |
|||
- networkpolicies |
|||
- nodes |
|||
- namespaces |
|||
- pods |
|||
- serviceaccounts |
|||
verbs: |
|||
- get |
|||
- list |
|||
- watch |
|||
- apiGroups: |
|||
- crd.projectcalico.org |
|||
resources: |
|||
- globalnetworkpolicies |
|||
- networkpolicies |
|||
- clusterinformations |
|||
- hostendpoints |
|||
- globalnetworksets |
|||
- networksets |
|||
- bgpconfigurations |
|||
- bgppeers |
|||
- felixconfigurations |
|||
- kubecontrollersconfigurations |
|||
- ippools |
|||
- ipreservations |
|||
- ipamblocks |
|||
- blockaffinities |
|||
- caliconodestatuses |
|||
verbs: |
|||
- get |
|||
- list |
|||
- watch |
|||
- create |
|||
- update |
|||
- delete |
|||
- apiGroups: |
|||
- policy |
|||
resourceNames: |
|||
- calico-apiserver |
|||
resources: |
|||
- podsecuritypolicies |
|||
verbs: |
|||
- use |
|||
|
|||
--- |
|||
|
|||
apiVersion: rbac.authorization.k8s.io/v1 |
|||
kind: ClusterRole |
|||
metadata: |
|||
name: calico-extension-apiserver-auth-access |
|||
rules: |
|||
- apiGroups: |
|||
- "" |
|||
resourceNames: |
|||
- extension-apiserver-authentication |
|||
resources: |
|||
- configmaps |
|||
verbs: |
|||
- list |
|||
- watch |
|||
- get |
|||
- apiGroups: |
|||
- rbac.authorization.k8s.io |
|||
resources: |
|||
- clusterroles |
|||
- clusterrolebindings |
|||
- roles |
|||
- rolebindings |
|||
verbs: |
|||
- get |
|||
- list |
|||
- watch |
|||
|
|||
--- |
|||
|
|||
apiVersion: rbac.authorization.k8s.io/v1 |
|||
kind: ClusterRole |
|||
metadata: |
|||
name: calico-webhook-reader |
|||
rules: |
|||
- apiGroups: |
|||
- admissionregistration.k8s.io |
|||
resources: |
|||
- mutatingwebhookconfigurations |
|||
- validatingwebhookconfigurations |
|||
verbs: |
|||
- get |
|||
- list |
|||
- watch |
|||
|
|||
--- |
|||
|
|||
apiVersion: rbac.authorization.k8s.io/v1 |
|||
kind: ClusterRoleBinding |
|||
metadata: |
|||
name: calico-apiserver-access-crds |
|||
roleRef: |
|||
apiGroup: rbac.authorization.k8s.io |
|||
kind: ClusterRole |
|||
name: calico-crds |
|||
subjects: |
|||
- kind: ServiceAccount |
|||
name: calico-apiserver |
|||
namespace: calico-apiserver |
|||
|
|||
--- |
|||
|
|||
apiVersion: rbac.authorization.k8s.io/v1 |
|||
kind: ClusterRoleBinding |
|||
metadata: |
|||
name: calico-apiserver-delegate-auth |
|||
roleRef: |
|||
apiGroup: rbac.authorization.k8s.io |
|||
kind: ClusterRole |
|||
name: system:auth-delegator |
|||
subjects: |
|||
- kind: ServiceAccount |
|||
name: calico-apiserver |
|||
namespace: calico-apiserver |
|||
|
|||
--- |
|||
|
|||
apiVersion: rbac.authorization.k8s.io/v1 |
|||
kind: ClusterRoleBinding |
|||
metadata: |
|||
name: calico-apiserver-webhook-reader |
|||
roleRef: |
|||
apiGroup: rbac.authorization.k8s.io |
|||
kind: ClusterRole |
|||
name: calico-webhook-reader |
|||
subjects: |
|||
- kind: ServiceAccount |
|||
name: calico-apiserver |
|||
namespace: calico-apiserver |
|||
|
|||
--- |
|||
|
|||
apiVersion: rbac.authorization.k8s.io/v1 |
|||
kind: ClusterRoleBinding |
|||
metadata: |
|||
name: calico-extension-apiserver-auth-access |
|||
roleRef: |
|||
apiGroup: rbac.authorization.k8s.io |
|||
kind: ClusterRole |
|||
name: calico-extension-apiserver-auth-access |
|||
subjects: |
|||
- kind: ServiceAccount |
|||
name: calico-apiserver |
|||
namespace: calico-apiserver |
|||
|
|||
--- |
|||
|
|||
apiVersion: policy/v1beta1 |
|||
kind: PodSecurityPolicy |
|||
metadata: |
|||
annotations: |
|||
seccomp.security.alpha.kubernetes.io/allowedProfileNames: '*' |
|||
name: calico-apiserver |
|||
spec: |
|||
allowPrivilegeEscalation: false |
|||
fsGroup: |
|||
ranges: |
|||
- max: 65535 |
|||
min: 1 |
|||
rule: MustRunAs |
|||
hostPorts: |
|||
- max: 65535 |
|||
min: 0 |
|||
requiredDropCapabilities: |
|||
- ALL |
|||
runAsUser: |
|||
rule: RunAsAny |
|||
seLinux: |
|||
rule: RunAsAny |
|||
supplementalGroups: |
|||
ranges: |
|||
- max: 65535 |
|||
min: 1 |
|||
rule: MustRunAs |
|||
volumes: |
|||
- secret |
Write
Preview
Loading…
Cancel
Save