Tenho em casa duas máquinas v1122.2.0 estáveis CoreOS. ambos são registrados em discovery.etcd.io corretamente. (Eu vejo os dois registrados no link quando eu navego até o URL de descoberta).
o primeiro servidor é 10.79.218.2 e o segundo é 10.79.218.3.
Estou tentando configurar o etcd para tls. então criei os certificados necessários e configurei o etcd2 para o tls. toda a configuração (do primeiro servidor com o ip local de 10.79.218.2) está no arquivo cloud-config.yml:
#cloud-config
write_files:
- path: "/etc/ssl/etcd/ca.pem"
permissions: "0600"
owner: "etcd:etcd"
content: |
-----BEGIN CERTIFICATE-----
...
-----END CERTIFICATE-----
- path: "/etc/ssl/etcd/server1.pem"
permissions: "0600"
owner: "etcd:etcd"
content: |
-----BEGIN CERTIFICATE-----
...
-----END CERTIFICATE-----
- path: "/etc/ssl/etcd/server1-key.pem"
permissions: "0600"
owner: "etcd:etcd"
content: |
-----BEGIN EC PRIVATE KEY-----
...
-----END EC PRIVATE KEY-----
- path: "/etc/kubernetes/cni/net.d/10-calico.conf"
content: |
{
"name": "calico",
"type": "flannel",
"delegate": {
"type": "calico",
"etcd_endpoints": "https://10.79.218.2:2379,https://10.79.218.3:2379",
"log_level": "none",
"log_level_stderr": "info",
"hostname": "10.79.218.2",
"policy": {
"type": "k8s",
"k8s_api_root": "http://127.0.0.1:8080/api/v1/"
}
}
}
- path: "/etc/kubernetes/manifests/policy-controller.yaml"
content: |
apiVersion: v1
kind: Pod
metadata:
name: calico-policy-controller
namespace: calico-system
spec:
hostNetwork: true
containers:
# The Calico policy controller.
- name: k8s-policy-controller
image: calico/kube-policy-controller:v0.2.0
env:
- name: ETCD_ENDPOINTS
value: "https://10.79.218.2:2379,http://10.79.218.3:2379"
- name: K8S_API
value: "http://127.0.0.1:8080"
- name: LEADER_ELECTION
value: "true"
# Leader election container used by the policy controller.
- name: leader-elector
image: quay.io/calico/leader-elector:v0.1.0
imagePullPolicy: IfNotPresent
args:
- "--election=calico-policy-election"
- "--election-namespace=calico-system"
- "--http=127.0.0.1:4040"
- path: "/etc/kubernetes/manifests/kube-scheduler.yaml"
content: |
apiVersion: v1
kind: Pod
metadata:
name: kube-scheduler
namespace: kube-system
spec:
hostNetwork: true
containers:
- name: kube-scheduler
image: quay.io/coreos/hyperkube:v1.3.6_coreos.0
command:
- /hyperkube
- scheduler
- --master=http://127.0.0.1:8080
- --leader-elect=true
livenessProbe:
httpGet:
host: 127.0.0.1
path: /healthz
port: 10251
initialDelaySeconds: 15
timeoutSeconds: 1
- path: "/etc/kubernetes/manifests/kube-controller-manager.yaml"
content: |
apiVersion: v1
kind: Pod
metadata:
name: kube-controller-manager
namespace: kube-system
spec:
hostNetwork: true
containers:
- name: kube-controller-manager
image: quay.io/coreos/hyperkube:v1.3.6_coreos.0
command:
- /hyperkube
- controller-manager
- --master=http://127.0.0.1:8080
- --leader-elect=true
- --service-account-private-key-file=/etc/kubernetes/ssl/apiserver-key.pem
- --root-ca-file=/etc/kubernetes/ssl/ca.pem
livenessProbe:
httpGet:
host: 127.0.0.1
path: /healthz
port: 10252
initialDelaySeconds: 15
timeoutSeconds: 1
volumeMounts:
- mountPath: /etc/kubernetes/ssl
name: ssl-certs-kubernetes
readOnly: true
- mountPath: /etc/ssl/certs
name: ssl-certs-host
readOnly: true
volumes:
- hostPath:
path: /etc/kubernetes/ssl
name: ssl-certs-kubernetes
- hostPath:
path: /usr/share/ca-certificates
name: ssl-certs-host
- path: "/etc/kubernetes/manifests/kube-proxy.yaml"
content: |
apiVersion: v1
kind: Pod
metadata:
name: kube-proxy
namespace: kube-system
spec:
hostNetwork: true
containers:
- name: kube-proxy
image: quay.io/coreos/hyperkube:v1.3.6_coreos.0
command:
- /hyperkube
- proxy
- --master=http://127.0.0.1:8080
- --proxy-mode=iptables
securityContext:
privileged: true
volumeMounts:
- mountPath: /etc/ssl/certs
name: ssl-certs-host
readOnly: true
volumes:
- hostPath:
path: /usr/share/ca-certificates
name: ssl-certs-host
- path: "/etc/kubernetes/manifests/kube-apiserver.yaml"
content: |
apiVersion: v1
kind: Pod
metadata:
name: kube-apiserver
namespace: kube-system
spec:
hostNetwork: true
containers:
- name: kube-apiserver
image: quay.io/coreos/hyperkube:v1.3.6_coreos.0
command:
- /hyperkube
- apiserver
- --bind-address=0.0.0.0
- --etcd-servers=https://10.79.218.2:2379,https://10.79.218.3:2379
- --allow-privileged=true
- --service-cluster-ip-range=10.0.0.0/24
- --secure-port=443
- --advertise-address=10.79.218.2
- --admission-control=NamespaceLifecycle,LimitRanger,ServiceAccount,ResourceQuota
- --tls-cert-file=/etc/kubernetes/ssl/apiserver.pem
- --tls-private-key-file=/etc/kubernetes/ssl/apiserver-key.pem
- --client-ca-file=/etc/kubernetes/ssl/ca.pem
- --service-account-key-file=/etc/kubernetes/ssl/apiserver-key.pem
- --runtime-config=extensions/v1beta1=true,extensions/v1beta1/networkpolicies=true
ports:
- containerPort: 443
hostPort: 443
name: https
- containerPort: 8080
hostPort: 8080
name: local
volumeMounts:
- mountPath: /etc/kubernetes/ssl
name: ssl-certs-kubernetes
readOnly: true
- mountPath: /etc/ssl/certs
name: ssl-certs-host
readOnly: true
volumes:
- hostPath:
path: /etc/kubernetes/ssl
name: ssl-certs-kubernetes
- hostPath:
path: /usr/share/ca-certificates
name: ssl-certs-host
- path: "/etc/flannel/options.env"
content: |
FLANNELD_IFACE=10.79.218.2
FLANNELD_ETCD_ENDPOINTS=https://10.79.218.2:2379,https://10.79.218.3:2379
- path: "/etc/kubernetes/ssl/ca.pem"
permissions: "0600"
owner: "root:root"
content: |
-----BEGIN CERTIFICATE-----
...
-----END CERTIFICATE-----
- path: "/etc/kubernetes/ssl/apiserver.pem"
permissions: "0600"
owner: "root:root"
content: |
-----BEGIN CERTIFICATE-----
...
-----END CERTIFICATE-----
- path: "/etc/kubernetes/ssl/apiserver-key.pem"
permissions: "0600"
owner: "root:root"
content: |
-----BEGIN RSA PRIVATE KEY-----
...
-----END RSA PRIVATE KEY-----
ssh_authorized_keys:
- "ssh-rsa ... ufk@ufk-osx-music"
coreos:
update:
reboot-strategy: etcd-lock
etcd2:
discovery: https://discovery.etcd.io/...
# multi-region and multi-cloud deployments need to use $public_ipv4
advertise-client-urls: https://10.79.218.2:2379
initial-advertise-peer-urls: https://10.79.218.2:2380
# listen on both the official ports and the legacy ports
# legacy ports can be omitted if your application doesn't depend on them
listen-client-urls: https://0.0.0.0:2379
listen-peer-urls: https://10.79.218.2:2380
units:
- name: 00-enp4s0.network
runtime: true
content: |
[Match]
Name=enp4s0
[Network]
Address=10.79.218.2/24
Gateway=10.79.218.232
DNS=8.8.8.8
- name: var-lib-rkt.mount
enable: true
command: start
content: |
[Mount]
What=/dev/disk/by-uuid/23cc3284-e121-4448-b755-b74b5a022251
Where=/var/lib/rkt
Type=btrfs
Options=loop,discard
- name: etcd2.service
command: start
drop-ins:
- name: 30-certs.conf
content: |
[Service]
Environment="ETCD_CERT_FILE=/etc/ssl/etcd/server1.pem"
Environment="ETCD_KEY_FILE=/etc/ssl/etcd/server1-key.pem"
Environment="ETCD_TRUSTED_CA_FILE=/etc/ssl/etcd/ca.pem"
Environment="ETCD_CLIENT_CERT_AUTH=true"
Environment="ETCD_PEER_CERT_FILE=/etc/ssl/etcd/server1.pem"
Environment="ETCD_PEER_KEY_FILE=/etc/ssl/etcd/server1-key.pem"
Environment="ETCD_PEER_TRUSTED_CA_FILE=/etc/ssl/etcd/ca.pem"
Environment="ETCD_PEER_CLIENT_CERT_AUTH=true"
- name: flanneld.service
command: start
drop-ins:
- name: 50-network-config.conf
content: |
[Service]
ExecStartPre=/usr/bin/etcdctl set /coreos.com/network/config '{"Network":"10.1.0.0/16", "Backend": {"Type": "vxlan"}}'
- name: 40-ExecStartPre-symlink.conf
content: |
[Service]
ExecStartPre=/usr/bin/ln -sf /etc/flannel/options.env /run/flannel/options.env
- name: kubelet.service
enable: false
content: |
[Service]
ExecStartPre=/usr/bin/mkdir -p /etc/kubernetes/manifests
Environment=KUBELET_VERSION=v1.3.6_coreos.0
ExecStart=/usr/lib/coreos/kubelet-wrapper \
--api-servers=http://127.0.0.1:8080 \
--network-plugin-dir=/etc/kubernetes/cni/net.d \
--network-plugin=cni \
--register-schedulable=false \
--allow-privileged=true \
--config=/etc/kubernetes/manifests \
--hostname-override=10.79.218.2 \
--cluster-dns=8.8.8.8 \
--cluster-domain=cluster.local
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target
- name: calico-node.service
enable: false
content: |
[Unit]
Description=Calico per-host agent
Requires=network-online.target
After=network-online.target
[Service]
Slice=machine.slice
Environment=CALICO_DISABLE_FILE_LOGGING=true
Environment=HOSTNAME=10.79.218.2
Environment=IP=${ADVERTISE_IP}
Environment=FELIX_FELIXHOSTNAME=10.79.218.2
Environment=CALICO_NETWORKING=false
Environment=NO_DEFAULT_POOLS=true
Environment=ETCD_ENDPOINTS=https://10.79.218.2:2379,https://10.79.218.3:2379
ExecStart=/usr/bin/rkt run --inherit-env --stage1-from-dir=stage1-fly.aci \
--volume=modules,kind=host,source=/lib/modules,readOnly=false \
--mount=volume=modules,target=/lib/modules \
--trust-keys-from-https quay.io/calico/node:v0.19.0
KillMode=mixed
Restart=always
TimeoutStartSec=0
[Install]
WantedBy=multi-user.target
- eu removi coisas importantes (como chaves) e as substitui por
...
- eu tenho o kubelet e o calico configurados, mas desativados por enquanto, até que eu tenha o etcd2 instalado e funcionando com tls.
então estou tentando executar etcdctl
do meu laptop do mac pro para listar os membros do etcd2 (enquanto estiver conectado à mesma rede local) usando o comando
./etcdctl --endpoints="https://10.79.218.2:2379,https://10.79.218.3:2379" --key-file="./cfssl/client-key.pem" --cert-file="./cfssl/client.pem" --ca-file="./cfssl/ca.pem" member list
e eu recebo em resposta
Try '--no-sync' if you want to access non-published client endpoints(https://10.79.218.2:2379,https://10.79.218.3:2379).
Error: client: no endpoints available
executando o mesmo comando com --no-sync
resulta o seguinte:
Failed to get leader: client: etcd cluster is unavailable or misconfigured
Eu criei os certificados conforme descrito no link
o que estou perdendo?
obrigado
atualizar
então eu descobri o link . e criei novamente os certificados usando esse script e configurei meus servidores coreos etcd2 com esses scripts.
criou os seguintes certificados:
ca-key.pem
ca.csr
ca.pem
etcd1-key.pem
etcd1.csr
etcd1.pem
etcd2-key.pem
etcd2.csr
etcd2.pem
etcd3-key.pem
etcd3.csr
etcd3.pem
proxy1-key.pem
proxy1.csr
proxy1.pem
o problema é que eu não vejo nenhum certificado de cliente .. então eu não entendo muito bem quais certificados passar como parâmetros para o etcdctl trabalhar na minha área de trabalho. alguma idéia?
atualização 2
então eu achei como usar etcdctl com tls .. eu acho. mas ainda recebo erros.
Eu executei o seguinte comando:
/etcdctl --endpoint=https://10.79.218.2:2379 --ca-file=./certs/ca.pem --cert-file=./certs/etcd1.pem --key-file=./certs/etcd1-key.pem --no-sync ls
mas recebo o erro
Error: client: etcd cluster is unavailable or misconfigured
error #0: x509: cannot validate certificate for 10.79.218.2 because it doesn't contain any IP SANs