Added seed code for caas-etcd.
Change-Id: I5825aa704e79ac5b6385ac89c3b8c89d1f98196f
Signed-off-by: Szekeres, Balazs (Nokia - HU/Budapest) <balazs.szekeres@nokia.com>
--- /dev/null
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
--- /dev/null
+---
+# Copyright 2019 Nokia
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# cmframework.requires: master_kubelet.yaml
+- hosts: caas_master
+ strategy: free
+ become: true
+ become_user: "{{ users.admin_user_name }}"
+ roles:
+ - etcd
--- /dev/null
+---
+# Copyright 2019 Nokia
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+dependencies:
+ - role: creategroup
+ _name: caas_etcd
+ _gid: "{{ caas.uid.caas_etcd }}"
+ become: true
+ become_user: "root"
+
+ - role: createuser
+ _name: caas_etcd
+ _group: caas_etcd
+ _groups: ''
+ _shell: /sbin/nologin
+ _home: /var/lib/etcd
+ _uid: "{{ caas.uid.caas_etcd }}"
+ become: true
+ become_user: "root"
+
+ - role: creategroup
+ _name: kube
+ _gid: "{{ caas.uid.kube }}"
+ become: true
+ become_user: "root"
+
+ - role: createuser
+ _name: kube
+ _group: kube
+ _groups: ''
+ _shell: /sbin/nologin
+ _home: /
+ _uid: "{{ caas.uid.kube }}"
+ become: true
+ become_user: "root"
+
+ - role: cert
+ instance: "etcd{{ nodeindex }}"
+ cert_path: /etc/etcd/ssl
+ alt_names:
+ ip:
+ - "{{ ansible_host }}"
+ add_users:
+ - caas_etcd
+ - kube # needed for apiserver
+ become: true
+ become_user: "root"
+
+ - role: docker_image_load
+ images:
+ - etcd
--- /dev/null
+---
+# Copyright 2019 Nokia
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+- set_fact:
+ counter_add_member: "{{ item.0 }}"
+
+- set_fact:
+ etcd_address_add_member: "{{ item.1 }}"
+
+- set_fact:
+ expected_etcd_number: "{{ counter_add_member | int + 2 }}"
+
+- set_fact:
+ current_cluster_size: 0
+
+- name: wait for healthy cluster
+ shell: "/usr/bin/curl https://{{ ansible_host }}:{{ caas.etcd_api_port }}/health --cacert /etc/etcd/ssl/ca.pem --cert /etc/etcd/ssl/etcd{{ nodeindex }}.pem --key /etc/etcd/ssl/etcd{{ nodeindex }}-key.pem"
+ register: result
+ until: result.stdout.find('true') != -1
+ retries: 50
+ delay: 6
+ become_user: "root"
+
+- name: etcd docker id
+ shell: "docker ps | grep etcd | grep -v pause | awk -F' ' '{ print $1 }'"
+ environment:
+ DOCKER_HOST: "tcp://{{ networking.infra_internal.ip }}:2375"
+ DOCKER_TLS_VERIFY: "1"
+ DOCKER_CERT_PATH: "/etc/docker"
+ register: etcd_container_id_add_member
+ until: etcd_container_id_add_member.stdout
+ retries: 50
+ delay: 6
+
+- set_fact:
+ etcd_container_id_outer: "{{ etcd_container_id_add_member.stdout }}"
+
+- import_tasks: try_add_member.yml
+ until: current_cluster_size|int >= expected_etcd_number
+ retries: 10
+ delay: 5
+
+- name: wait for healthy cluster
+ shell: "/usr/bin/curl https://{{ ansible_host }}:{{ caas.etcd_api_port }}/health --cacert /etc/etcd/ssl/ca.pem --cert /etc/etcd/ssl/etcd{{ nodeindex }}.pem --key /etc/etcd/ssl/etcd{{ nodeindex }}-key.pem"
+ register: result
+ until: result.stdout.find('true') != -1
+ retries: 50
+ delay: 5
+ become_user: "root"
+
--- /dev/null
+---
+# Copyright 2019 Nokia
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+- name: create libs
+ file:
+ name: /var/lib/etcd
+ state: directory
+ owner: caas_etcd
+ group: caas_etcd
+ become_user: "root"
+
+- set_fact:
+ master_list: "{{ groups.caas_master | list }}"
+
+- include_tasks: wait_for_etcd.yml
+ with_indexed_items:
+ - "{{ master_list }}"
+ when: ( groups['caas_master']|length|int > 1 ) and ( not nodename | search('caas_master1'))
+
+- name: template etcd manifest
+ template:
+ src: etcd.yml
+ dest: /etc/kubernetes/manifests/etcd.yml
+ become_user: "root"
+
+- name: wait for container to start
+ wait_for:
+ host: "{{ ansible_host }}"
+ port: "{{ caas.etcd_api_port }}"
+ state: started
+ timeout: "{{ caas.container_wait_timeout }}"
+ become_user: "root"
+
+- include_tasks: add_member.yml
+ with_indexed_items:
+ - "{{ hostvars[groups.caas_master[1]]['networking']['infra_internal']['ip'] }}"
+ - "{{ hostvars[groups.caas_master[2]]['networking']['infra_internal']['ip'] }}"
+ when: ( nodename | search("caas_master1") ) and ( groups['caas_master']|length|int > 1 )
+
+- name: etcd docker id
+ shell: "docker ps | grep etcd | grep -v pause | awk -F' ' '{ print $1 }'"
+ environment:
+ DOCKER_HOST: "tcp://{{ networking.infra_internal.ip }}:2375"
+ DOCKER_TLS_VERIFY: "1"
+ DOCKER_CERT_PATH: "/etc/docker"
+ register: etcd_container_id
+ until: etcd_container_id.stdout
+ delay: 5
+ retries: 60
+
+- name: sync all etcd
+ shell: "docker exec -t {{ etcd_container_id.stdout }} etcdctl3 member list | grep started | wc -l"
+ environment:
+ DOCKER_HOST: "tcp://{{ networking.infra_internal.ip }}:2375"
+ DOCKER_TLS_VERIFY: "1"
+ DOCKER_CERT_PATH: "/etc/docker"
+ register: result
+ until: result.stdout|int == master_list|length|int
+ delay: 5
+ retries: 100
+
--- /dev/null
+---
+# Copyright 2019 Nokia
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+- name: Add member
+ shell: 'echo $(docker exec -t {{ etcd_container_id_outer }} etcdctl3 member add etcd{{ expected_etcd_number }} --peer-urls="https://{{ etcd_address_add_member }}:{{ caas.etcd_peer_port}}")'
+ environment:
+ DOCKER_HOST: "tcp://{{ networking.infra_internal.ip }}:2375"
+ DOCKER_TLS_VERIFY: "1"
+ DOCKER_CERT_PATH: "/etc/docker"
+ register: member_add_result
+ until: (member_add_result.stdout.find("exists") != -1 ) or (member_add_result.stdout.find("added") != -1 )
+ delay: 10
+ retries: 100
+
+- name: Check if member is added successfuly
+ shell: 'docker exec -t {{ etcd_container_id_outer }} etcdctl3 member list | grep -i https | wc -l'
+ environment:
+ DOCKER_HOST: "tcp://{{ networking.infra_internal.ip }}:2375"
+ DOCKER_TLS_VERIFY: "1"
+ DOCKER_CERT_PATH: "/etc/docker"
+ register: addresult
+
+- set_fact:
+ current_cluster_size: "{{ addresult.stdout }}"
--- /dev/null
+---
+# Copyright 2019 Nokia
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+- set_fact:
+ counter_wait_for: "{{ item.0 }}"
+
+- set_fact:
+ current_oam_wait_for: "{{ item.1 }}"
+
+- set_fact:
+ etcd_number_wait_for: "{{ counter_wait_for | int + 2 }}"
+
+- set_fact:
+ expexted_oam_to_run: "caas_master{{ counter_wait_for | int + 2 }}"
+
+- name: wait for a running etcd on caas_master node from the next caas_master nodes
+ shell: "/usr/bin/curl https://{{ hostvars[current_oam_wait_for]['networking']['infra_internal']['ip'] }}:{{ caas.etcd_api_port }}/health --cacert /etc/etcd/ssl/ca.pem --cert /etc/etcd/ssl/etcd{{ etcd_number_wait_for }}.pem --key /etc/etcd/ssl/etcd{{ etcd_number_wait_for }}-key.pem"
+ register: result
+ until: ( result.stdout.find('true') != -1 ) or ( result.stdout.find('false') != -1 )
+ retries: 500
+ delay: 6
+ when: nodename | search( expexted_oam_to_run )
+ become_user: "root"
+
--- /dev/null
+{#
+Copyright 2019 Nokia
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+#}
+---
+apiVersion: v1
+kind: Pod
+metadata:
+ name: etcd
+ namespace: kube-system
+spec:
+ hostNetwork: true
+ dnsPolicy: ClusterFirst
+ securityContext:
+ runAsUser: {{ caas.uid.caas_etcd }}
+ containers:
+ - name: kube-etcd
+ image: {{ container_image_names | select('search', '/etcd') | list | last }}
+ command: ["/usr/bin/etcd"]
+ env:
+ - name: PORT
+ value: "{{ caas.etcd_api_port }}"
+ - name: ETCD_NAME
+ value: "etcd{{ nodeindex }}"
+ - name: ETCD_DATA_DIR
+ value: "/var/lib/etcd/etcd{{ nodeindex }}.etcd"
+ - name: ETCD_ADVERTISE_CLIENT_URLS
+ value: "https://{{ ansible_host }}:{{ caas.etcd_api_port }}"
+ - name: ETCD_LISTEN_CLIENT_URLS
+ value: "https://{{ ansible_host }}:{{ caas.etcd_api_port }}"
+ - name: ETCD_CLIENT_CERT_AUTH
+ value: "true"
+ - name: ETCD_TRUSTED_CA_FILE
+ value: "/etc/etcd/ssl/ca.pem"
+ - name: ETCD_CERT_FILE
+ value: "/etc/etcd/ssl/etcd{{ nodeindex }}.pem"
+ - name: ETCD_KEY_FILE
+ value: "/etc/etcd/ssl/etcd{{ nodeindex }}-key.pem"
+ - name: ETCD_MAX_WALS
+ value: "1"
+ - name: ETCD_LOG_PACKAGE_LEVELS
+ value: "etcdserver=CRITICAL,etcdmain=CRITICAL"
+ - name: ETCD_INITIAL_ADVERTISE_PEER_URLS
+ value: "https://{{ ansible_host }}:{{ caas.etcd_peer_port }}"
+ - name: ETCD_LISTEN_PEER_URLS
+ value: "https://{{ ansible_host }}:{{ caas.etcd_peer_port }}"
+ - name: ETCD_PEER_CLIENT_CERT_AUTH
+ value: "true"
+ - name: ETCD_PEER_TRUSTED_CA_FILE
+ value: "/etc/etcd/ssl/ca.pem"
+ - name: ETCD_PEER_CERT_FILE
+ value: "/etc/etcd/ssl/etcd{{ nodeindex }}.pem"
+ - name: ETCD_PEER_KEY_FILE
+ value: "/etc/etcd/ssl/etcd{{ nodeindex }}-key.pem"
+{% if nodename | search("caas_master1") %}
+ - name: ETCD_INITIAL_CLUSTER
+ value: "etcd1=https://{{ hostvars[groups.caas_master[0]]['networking']['infra_internal']['ip'] }}:{{ caas.etcd_peer_port }}"
+{% else %}
+ - name: ETCD_INITIAL_CLUSTER_STATE
+ value: "existing"
+{% endif %}
+{% if nodename | search("caas_master2") %}
+ - name: ETCD_INITIAL_CLUSTER
+ value: "etcd1=https://{{ hostvars[groups.caas_master[0]]['networking']['infra_internal']['ip'] }}:{{ caas.etcd_peer_port }},etcd2=https://{{ hostvars[groups.caas_master[1]]['networking']['infra_internal']['ip'] }}:{{ caas.etcd_peer_port }}"
+{% endif %}
+{% if nodename | search("caas_master3") %}
+ - name: ETCD_INITIAL_CLUSTER
+ value: "etcd1=https://{{ hostvars[groups.caas_master[0]]['networking']['infra_internal']['ip'] }}:{{ caas.etcd_peer_port }},etcd2=https://{{ hostvars[groups.caas_master[1]]['networking']['infra_internal']['ip'] }}:{{ caas.etcd_peer_port }},etcd3=https://{{ hostvars[groups.caas_master[2]]['networking']['infra_internal']['ip'] }}:{{ caas.etcd_peer_port }}"
+{% endif %}
+ - name: ETCD_LISTENONINTERFACE
+ value: "{{ networking.infra_internal.interface }}"
+ volumeMounts:
+ - name: store
+ mountPath: /var/lib/etcd
+ - name: etcd-config
+ mountPath: /etcd-config
+ - name: secret
+ mountPath: /etc/etcd/ssl
+ readOnly: true
+ volumes:
+ - name: store
+ hostPath:
+ path: /var/lib/etcd
+ - name: etcd-config
+ emptyDir: {}
+ - name: secret
+ hostPath:
+ path: /etc/etcd/ssl
--- /dev/null
+# Copyright 2019 Nokia
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+%define COMPONENT etcd
+%define RPM_NAME caas-%{COMPONENT}
+%define RPM_MAJOR_VERSION 3.3.12
+%define RPM_MINOR_VERSION 1
+%define IMAGE_TAG %{RPM_MAJOR_VERSION}-%{RPM_MINOR_VERSION}
+%define docker_build_dir %{_builddir}/%{RPM_NAME}-%{RPM_MAJOR_VERSION}/docker-build
+%define docker_save_dir %{_builddir}/%{RPM_NAME}-%{RPM_MAJOR_VERSION}/docker-save
+
+Name: %{RPM_NAME}
+Version: %{RPM_MAJOR_VERSION}
+Release: %{RPM_MINOR_VERSION}%{?dist}
+Summary: Containers as a Service %{COMPONENT} component
+License: %{_platform_license} and MIT license and BSD and Apache License and Lesser General Public License
+URL: https://github.com/etcd-io/etcd
+BuildArch: x86_64
+Vendor: %{_platform_vendor} and etcd-io/etcd unmodified
+Source0: %{name}-%{version}.tar.gz
+
+Requires: docker-ce >= 18.09.2
+BuildRequires: docker-ce-cli >= 18.09.2
+
+%description
+This rpm contains the %{COMPONENT} container for CaaS subsystem.
+This container contains the %{COMPONENT} service.
+
+%prep
+%autosetup
+
+%build
+docker build \
+ --network=host \
+ --no-cache \
+ --force-rm \
+ --build-arg HTTP_PROXY="${http_proxy}" \
+ --build-arg HTTPS_PROXY="${https_proxy}" \
+ --build-arg NO_PROXY="${no_proxy}" \
+ --build-arg http_proxy="${http_proxy}" \
+ --build-arg https_proxy="${https_proxy}" \
+ --build-arg no_proxy="${no_proxy}" \
+ --build-arg ETCD_VERSION="%{version}" \
+ --tag %{COMPONENT}:%{IMAGE_TAG} \
+ %{docker_build_dir}/%{COMPONENT}/
+mkdir -p %{docker_save_dir}/
+docker save %{COMPONENT}:%{IMAGE_TAG} | gzip -c > %{docker_save_dir}/%{COMPONENT}:%{IMAGE_TAG}.tar
+docker rmi %{COMPONENT}:%{IMAGE_TAG}
+
+
+%install
+mkdir -p %{buildroot}/%{_caas_container_tar_path}
+rsync -av %{docker_save_dir}/%{COMPONENT}:%{IMAGE_TAG}.tar %{buildroot}/%{_caas_container_tar_path}/
+
+mkdir -p %{buildroot}/%{_roles_path}
+rsync -av ansible/roles/* %{buildroot}/%{_roles_path}/
+
+install -D ansible/playbooks/etcd.yaml %{buildroot}/%{_playbooks_path}/etcd.yaml
+
+%files
+%{_caas_container_tar_path}/%{COMPONENT}:%{IMAGE_TAG}.tar
+%{_roles_path}/etcd
+%{_playbooks_path}/etcd.yaml
+
+%preun
+
+%post
+mkdir -p %{_postconfig_path}
+ln -s %{_playbooks_path}/etcd.yaml %{_postconfig_path}/
+
+%postun
+if [ $1 -eq 0 ]; then
+ rm -f %{_postconfig_path}/etcd.yaml
+fi
+
+%clean
+rm -rf ${buildroot}
--- /dev/null
+# Copyright 2019 Nokia
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+FROM alpine:3.9
+MAINTAINER Krisztian Lengyel <krisztian.lengyel@nokia.com>
+
+ARG ETCD_VERSION
+ENV GOPATH /build
+
+COPY get-package build-pip /usr/bin/
+COPY source-list.txt ${GOPATH}/
+
+
+COPY rootfs/ /
+
+RUN apk add py-pip \
+&& pip install --upgrade pip \
+&& mkdir -p ${GOPATH} \
+&& chmod 755 /usr/bin/build-pip /usr/bin/get-package \
+\
+&& adduser -u 143 -D -H -s /sbin/nologin caas_etcd \
+&& chmod +x /etcdctl3 \
+&& chmod 644 ${GOPATH}/source-list.txt \
+\
+&& apk add --no-cache --virtual .build-deps go godep curl tar build-base py-setuptools python2-dev \
+&& apk add --no-cache python2 py2-ipaddress py2-dnspython \
+\
+&& build-pip python-urllib3 python-etcd \
+\
+&& mkdir -p ${GOPATH}/src/github.com/coreos/etcd \
+&& curl -fsSL -k https://github.com/coreos/etcd/archive/v${ETCD_VERSION}.tar.gz | tar zx --strip-components=1 -C ${GOPATH}/src/github.com/coreos/etcd \
+&& cd ${GOPATH}/src/github.com/coreos/etcd \
+&& GOOS=linux ./build \
+&& mv bin/etcd /usr/bin/ \
+&& mv bin/etcdctl /usr/bin/ \
+&& mv /etcdctl3 /usr/bin/ \
+\
+&& apk del .build-deps \
+&& rm -rf ${GOPATH} \
+&& rm -rf /build
+
+
+WORKDIR /
--- /dev/null
+{
+ "bom": [
+ {
+ "name": "alpine-linux-container",
+ "version": "3.9",
+ "source-url": "https://github.com/gliderlabs/docker-alpine/archive/c4f4c7a6e14d6efeb9a160da464717e03d2cc3ee.tar.gz",
+ "foss": "yes"
+ },
+ {
+ "name": "musl",
+ "version": "1.1.20-r3",
+ "source-url": "https://git.alpinelinux.org/cgit/aports/tree/main/musl/APKBUILD?h=3.9-stable",
+ "foss": "yes"
+ },
+ {
+ "name": "busybox",
+ "version": "1.29.3-r10",
+ "source-url": "https://git.alpinelinux.org/cgit/aports/tree/main/busybox/APKBUILD?h=3.9-stable",
+ "foss": "yes"
+ },
+ {
+ "name": "alpine-baselayout",
+ "version": "3.1.0-r3",
+ "source-url": "https://git.alpinelinux.org/cgit/aports/tree/main/alpine-baselayout/APKBUILD?h=3.9-stable",
+ "foss": "yes"
+ },
+ {
+ "name": "alpine-keys",
+ "version": "2.1-r1",
+ "source-url": "https://git.alpinelinux.org/cgit/aports/tree/main/alpine-keys/APKBUILD?h=3.9-stable",
+ "foss": "yes"
+ },
+ {
+ "name": "libcrypto1.1",
+ "version": "1.1.1a-r1",
+ "source-url": "https://git.alpinelinux.org/aports/tree/main/openssl/APKBUILD?h=3.9-stable",
+ "foss": "yes"
+ },
+ {
+ "name": "libssl1.1",
+ "version": "1.1.1a-r1",
+ "source-url": "https://git.alpinelinux.org/aports/tree/main/openssl/APKBUILD?h=3.9-stable",
+ "foss": "yes"
+ },
+ {
+ "name": "ca-certificates-cacert",
+ "version": "20190108-r0",
+ "source-url": "https://git.alpinelinux.org/aports/tree/main/ca-certificates/APKBUILD?h=3.9-stable",
+ "foss": "yes"
+ },
+ {
+ "name": "libtls-standalone",
+ "version": "2.7.4-r6",
+ "source-url": "https://git.alpinelinux.org/aports/tree/main/libtls-standalone/APKBUILD?h=3.9-stable",
+ "foss": "yes"
+ },
+ {
+ "name": "ssl_client",
+ "version": "1.29.3-r10",
+ "source-url": "https://git.alpinelinux.org/aports/tree/main/busybox/APKBUILD?h=3.9-stable",
+ "foss": "yes"
+ },
+ {
+ "name": "zlib",
+ "version": "1.2.11-r1",
+ "source-url": "https://git.alpinelinux.org/cgit/aports/tree/main/zlib/APKBUILD?h=3.9-stable",
+ "foss": "yes"
+ },
+ {
+ "name": "apk-tools",
+ "version": "2.10.3-r1",
+ "source-url": "https://git.alpinelinux.org/cgit/aports/tree/main/apk-tools/APKBUILD?h=3.9-stable",
+ "foss": "yes"
+ },
+ {
+ "name": "scanelf",
+ "version": "1.2.3-r0",
+ "source-url": "https://git.alpinelinux.org/aports/tree/main/pax-utils/APKBUILD?h=3.9-stable",
+ "foss": "yes"
+ },
+ {
+ "name": "musl-utils",
+ "version": "1.1.20-r3",
+ "source-url": "https://git.alpinelinux.org/aports/tree/main/musl/APKBUILD?h=3.9-stable",
+ "foss": "yes"
+ },
+ {
+ "name": "libc-utils",
+ "version": "0.7.1-r0",
+ "source-url": "https://git.alpinelinux.org/cgit/aports/tree/main/libc-dev/APKBUILD?h=3.9-stable",
+ "foss": "yes"
+ },
+ {
+ "name": "libbz2",
+ "version": "1.0.6-r6",
+ "source-url": "https://git.alpinelinux.org/cgit/aports/tree/main/bzip2/APKBUILD?h=3.9-stable",
+ "foss": "yes"
+ },
+ {
+ "name": "expat",
+ "version": "2.2.6-r0",
+ "source-url": "https://git.alpinelinux.org/cgit/aports/tree/main/expat/APKBUILD?h=3.9-stable",
+ "foss": "yes"
+ },
+ {
+ "name": "libffi",
+ "version": "3.2.1-r6",
+ "source-url": "https://git.alpinelinux.org/cgit/aports/tree/main/libffi/APKBUILD?h=3.9-stable",
+ "foss": "yes"
+ },
+ {
+ "name": "gdbm",
+ "version": "1.13-r1",
+ "source-url": "https://git.alpinelinux.org/cgit/aports/tree/main/gdbm/APKBUILD?h=3.9-stable",
+ "foss": "yes"
+ },
+ {
+ "name": "ncurses-terminfo-base",
+ "version": "6.1_p20190105-r0",
+ "source-url": "https://git.alpinelinux.org/aports/tree/main/ncurses/APKBUILD?h=3.9-stable",
+ "foss": "yes"
+ },
+ {
+ "name": "ncurses-terminfo",
+ "version": "6.1_p20190105-r0",
+ "source-url": "https://git.alpinelinux.org/aports/tree/main/ncurses/APKBUILD?h=3.9-stable",
+ "foss": "yes"
+ },
+ {
+ "name": "ncurses-libs",
+ "version": "6.1_p20190105-r0",
+ "source-url": "https://git.alpinelinux.org/aports/tree/main/ncurses/APKBUILD?h=3.9-stable",
+ "foss": "yes"
+ },
+ {
+ "name": "readline",
+ "version": "7.0.003-r1",
+ "source-url": "https://git.alpinelinux.org/cgit/aports/tree/main/readline/APKBUILD?h=3.9-stable",
+ "foss": "yes"
+ },
+ {
+ "name": "sqlite-libs",
+ "version": "3.26.0-r3",
+ "source-url": "https://git.alpinelinux.org/aports/tree/main/sqlite/APKBUILD?h=3.9-stable",
+ "foss": "yes"
+ },
+ {
+ "name": "python2",
+ "version": "2.7.15-r3",
+ "source-url": "https://git.alpinelinux.org/cgit/aports/tree/main/python2/APKBUILD?h=3.9-stable",
+ "foss": "yes"
+ },
+ {
+ "name": "py-setuptools",
+ "version": "40.6.3-r0",
+ "source-url": "https://git.alpinelinux.org/cgit/aports/tree/main/py-setuptools/APKBUILD?h=3.9-stable",
+ "foss": "yes"
+ },
+ {
+ "name": "py2-pip",
+ "version": "18.1-r0",
+ "source-url": "https://git.alpinelinux.org/cgit/aports/tree/main/py2-pip/APKBUILD?h=3.9-stable",
+ "foss": "yes"
+ },
+ {
+ "name": "py2-dnspython",
+ "version": "1.15.0-r1",
+ "source-url": "https://git.alpinelinux.org/cgit/aports/tree/community/py-dnspython/APKBUILD?h=3.9-stable",
+ "foss": "yes"
+ },
+ {
+ "name": "py2-ipaddress",
+ "version": "1.0.22-r0",
+ "source-url": "https://git.alpinelinux.org/cgit/aports/tree/main/py-ipaddress/APKBUILD?h=3.9-stable",
+ "foss": "yes"
+ },
+ {
+ "name": "dnspython",
+ "version": "1.15.0",
+ "source-url": "https://github.com/rthalley/dnspython/archive/v1.15.0.tar.gz",
+ "foss": "yes"
+ },
+ {
+ "name": "ipaddress",
+ "version": "1.0.22",
+ "source-url": "https://github.com/phihag/ipaddress/archive/v1.0.22.tar.gz",
+ "foss": "yes"
+ },
+ {
+ "name": "pip",
+ "version": "19.0.2",
+ "source-url": "https://github.com/pypa/pip/archive/19.0.2.tar.gz",
+ "foss": "yes"
+ },
+ {
+ "name": "python-etcd",
+ "version": "0.4.5",
+ "source-url": "https://github.com/jplana/python-etcd/archive/0.4.5.tar.gz",
+ "foss": "yes"
+ },
+ {
+ "name": "setuptools",
+ "version": "40.6.3.post20190116",
+ "source-url": "https://git.alpinelinux.org/aports/tree/main/py-setuptools/APKBUILD?h=3.9-stable",
+ "foss": "yes"
+ },
+ {
+ "name": "urllib3",
+ "version": "1.24.1",
+ "source-url": "https://github.com/urllib3/urllib3/archive/1.24.1.tar.gz",
+ "foss": "yes"
+ },
+ {
+ "name": "etcd",
+ "version": "3.3.12",
+ "source-url": "https://github.com/coreos/etcd/archive/v3.3.12.tar.gz",
+ "foss": "yes"
+ }
+ ]
+}
--- /dev/null
+#!/bin/sh -e
+# Copyright 2019 Nokia
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+mkdir -p ${GOPATH}/pip
+cd ${GOPATH}/pip
+for MOD in ${@}
+do
+ get-package ${MOD}
+ python setup.py install
+ rm -rf *
+done
--- /dev/null
+#!/bin/sh -e
+# Copyright 2019 Nokia
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+URL=`cat ${GOPATH}/source-list.txt | grep "> ${1}" | cut -d'=' -f2`
+
+curl -fsSL -k ${URL} | tar zx --strip-components=1
--- /dev/null
+#!/bin/sh
+# Copyright 2019 Nokia
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+export ETCDCTL_API=3
+export IP=`ifconfig $ETCD_LISTENONINTERFACE | awk '/inet addr/{print substr($2,6)}'`
+/usr/bin/etcdctl --cacert /etc/etcd/ssl/ca.pem --cert /etc/etcd/ssl/etcd?.pem --key /etc/etcd/ssl/etcd?-key.pem --endpoints $IP:$PORT "$@"
--- /dev/null
+#############################
+ README
+
+- only parts of lines that match this regexp '>$NAME=.*' are parsed
+- dependencies are marked with '--' indentation
+ (now only pip modules have this, and it is based on their requirements.txt)
+- 'a-->' means it is a dependency of the alpine apk as well
+ (pip and alpine depencies do not match, strangely)
+
+#############################
+
+
+==========================
+# PIP modules #
+==========================
+> python-etcd=https://pypi.python.org/packages/a1/da/616a4d073642da5dd432e5289b7c1cb0963cc5dde23d1ecb8d726821ab41/python-etcd-0.4.5.tar.gz
+a--> python-urllib3=https://files.pythonhosted.org/packages/b1/53/37d82ab391393565f2f831b8eedbffd57db5a718216f82f1a8b4d381a1c1/urllib3-1.24.1.tar.gz