Add tool to check for jump server updates
[icn.git] / tools / software-bom.sh
1 #!/bin/bash
2 set -eu -o pipefail
3
4 SCRIPTDIR="$(readlink -f $(dirname ${BASH_SOURCE[0]}))"
5 LIBDIR="$(dirname ${SCRIPTDIR})/env/lib"
6 ICNDIR="$(dirname ${SCRIPTDIR})"
7
8 source $LIBDIR/common.sh
9
10 function table_header {
11     cat <<EOF
12 |Component|Link|Version|License|
13 |---|---|---|---|
14 EOF
15 }
16
17 function jump_server_os {
18     case $(awk '/m.vm.box = / {print $3}' ${ICNDIR}/Vagrantfile | tr -d "'") in
19         "intergratedcloudnative/ubuntu2004")
20             link="https://ubuntu.com/"
21             version="Ubuntu 20.04"
22             license="GPL-2.0"
23             ;;
24         *)
25             link="UNKNOWN"
26             version="UNKNOWN"
27             license="UNKNOWN"
28             ;;
29     esac
30     echo "|OS|${link}|${version}|${license}|"
31 }
32
33 function kubespray_version {
34     awk -F= '/KUBESPRAY_VERSION=/ {print $2}' ${ICNDIR}/deploy/kud/kud_bm_launch.sh
35 }
36
37 function jump_server_k8s {
38     local -r version=$(curl -sL https://raw.githubusercontent.com/kubernetes-sigs/kubespray/v$(kubespray_version)/roles/kubespray-defaults/defaults/main.yaml | awk '/kube_version:/ {print $2}')
39     echo "|Kubespray|https://github.com/kubernetes-sigs/kubespray|$(kubespray_version)|Apache-2.0|"
40     echo "|K8s|https://kubernetes.io/|${version}|Apache-2.0|"
41 }
42
43 function jump_server_cri {
44     local -r version=$(curl -sL https://raw.githubusercontent.com/kubernetes-sigs/kubespray/v$(kubespray_version)/roles/container-engine/docker/defaults/main.yml | awk '/docker_version:/ {print $2}' | tr -d "'")
45     echo "|Docker|https://www.docker.com/|${version}|Apache-2.0|"
46 }
47
48 function jump_server_cni {
49     # kud/hosting_providers/vagrant/inventory/group_vars/k8s-cluster.yml:kube_network_plugin: flannel
50     local -r version=$(curl -sL https://raw.githubusercontent.com/kubernetes-sigs/kubespray/v$(kubespray_version)/roles/download/defaults/main.yml | awk '/flannel_version:/ {print $2}' | tr -d '"')
51     echo "|Flannel|https://github.com/flannel-io/flannel|${version}|Apache-2.0|"
52 }
53
54 function jump_server_addons {
55     cat <<EOF
56 |Ironic|https://github.com/metal3-io/baremetal-operator|${BMO_VERSION}|Apache-2.0|
57 |cert-manager|https://cert-manager.io/|${CERT_MANAGER_VERSION}|Apache-2.0|
58 |Bare Metal Operator|https://github.com/metal3-io/baremetal-operator|${BMO_VERSION}|Apache-2.0|
59 |Cluster API|https://cluster-api.sigs.k8s.io/|${CAPI_VERSION}|Apache-2.0|
60 |Flux|https://fluxcd.io/|${FLUX_VERSION}|Apache-2.0|
61 EOF
62 }
63
64 function jump_server {
65     table_header
66     jump_server_os
67     jump_server_k8s
68     jump_server_cri
69     jump_server_cni
70     jump_server_addons
71 }
72
73 function jump_server_os_installed {
74     (
75         source /etc/os-release
76         case ${NAME} in
77             "Ubuntu") echo "|OS|https://ubuntu.com/|${NAME} ${VERSION_ID}|GPL-2.0|" ;;
78             *) echo "|OS|UNKNOWN|UNKNOWN|UNKNOWN" ;;
79         esac
80     )
81 }
82
83 function kubespray_version_installed {
84     awk -F= '/KUBESPRAY_VERSION=/ {print $2}' ${ICNDIR}/deploy/kud/kud_bm_launch.sh
85 }
86
87 function jump_server_k8s_installed {
88     local -r version=$(kubectl version -o json | jq -r '.serverVersion.gitVersion')
89     echo "|Kubespray|https://github.com/kubernetes-sigs/kubespray|$(kubespray_version)|Apache-2.0|" # TODO
90     echo "|K8s|https://kubernetes.io/|${version}|Apache-2.0|"
91 }
92
93 function jump_server_cri_installed {
94     local -r version=$(docker version --format '{{.Server.Version}}')
95     echo "|Docker|https://www.docker.com/|${version}|Apache-2.0|"
96 }
97
98 function jump_server_cni_installed {
99     local -r version=$(kubectl -n kube-system get daemonset kube-flannel -o jsonpath='{.spec.template.spec.containers[0].image}' | sed -e 's/[^:]\+:\(.*\)-.*/\1/')
100     echo "|Flannel|https://github.com/flannel-io/flannel|${version}|Apache-2.0|"
101 }
102
103 function jump_server_addons_installed {
104     local -r ironic_version=$(kubectl -n capm3-system get deployment capm3-ironic -o jsonpath='{.spec.template.spec.containers[0].image}' | sed -e 's/[^:]\+:\(.*\)/\1/')
105     local -r cert_manager_version=$(kubectl -n cert-manager get deployment cert-manager -o jsonpath='{.spec.template.spec.containers[0].image}' | sed -e 's/[^:]\+:\(.*\)/\1/')
106     local -r bmo_version=$(kubectl -n baremetal-operator-system get deployment baremetal-operator-controller-manager -o jsonpath='{.spec.template.spec.containers[0].image}' | sed -e 's/[^:]\+:\(.*\)/\1/')
107     local -r capi_version=$(clusterctl version -o json | jq -r '.clusterctl.gitVersion')
108     local -r flux_version=$(flux version | awk '/flux:/ {print $2}')
109     cat <<EOF
110 |Ironic|https://github.com/metal3-io/baremetal-operator|${ironic_version}|Apache-2.0|
111 |cert-manager|https://cert-manager.io/|${cert_manager_version}|Apache-2.0|
112 |Bare Metal Operator|https://github.com/metal3-io/baremetal-operator|${bmo_version}|Apache-2.0|
113 |Cluster API|https://cluster-api.sigs.k8s.io/|${capi_version}|Apache-2.0|
114 |Flux|https://fluxcd.io/|${FLUX_VERSION}|Apache-2.0|
115 EOF
116 }
117
118 function jump_server_installed {
119     table_header
120     jump_server_os_installed
121     jump_server_k8s_installed
122     jump_server_cri_installed
123     jump_server_cni_installed
124     jump_server_addons_installed
125 }
126
127 function compute_cluster_os {
128     case $(awk '/imageName:/ {print $2}' ${ICNDIR}/deploy/cluster/values.yaml) in
129         "focal-server-cloudimg-amd64.img")
130             link="https://ubuntu.com/"
131             version="Ubuntu 20.04"
132             license="GPL-2.0"
133             ;;
134         *)
135             link="UNKNOWN"
136             version="UNKNOWN"
137             license="UNKNOWN"
138             ;;
139     esac
140     echo "|OS|${link}|${version}|${license}"
141 }
142
143 function compute_cluster_k8s {
144     local -r version=$(awk '/k8sVersion:/ {print $2}' ${ICNDIR}/deploy/cluster/values.yaml)
145     echo "|K8s|https://kubernetes.io/|${version}|Apache-2.0|"
146 }
147
148 function compute_cluster_cri {
149     local -r version=$(awk '/containerdVersion:/ {print $2}' ${ICNDIR}/deploy/cluster/values.yaml)
150     echo "|containerd|https://containerd.io/|${version}|Apache-2.0|"
151 }
152
153 function compute_cluster_cni {
154     echo "|Calico|https://www.tigera.io/project-calico/|${CALICO_VERSION}|Apache-2.0|"
155 }
156
157 function git_repository_tag {
158     local -r source_yaml=$1
159     awk '/tag:/ {print $2}' ${source_yaml}
160 }
161
162 function image_tag {
163     local -r source_yaml=$1
164     local -r image_name=$2
165     awk -F: '/image:.*'"${image_name}"'/ {print $3}' ${source_yaml} | tr -d '"'
166 }
167
168 function ref_tag {
169     local -r kustomization_yaml=$1
170     awk -F= '/?ref=/ {print $2}' ${kustomization_yaml} | tr -d "'"
171 }
172
173 function iavf_driver_version {
174     eval $(curl -sL https://raw.githubusercontent.com/onap/multicloud-k8s/${KUD_VERSION}/kud/deployment_infra/installers/entrypoint-iavf-driver-installer.sh | awk '/IAVF_DRIVER_VERSION/ {print; exit}')
175     echo ${IAVF_DRIVER_VERSION}
176 }
177
178 function qat_driver_version {
179     eval $(curl -sL https://raw.githubusercontent.com/onap/multicloud-k8s/${KUD_VERSION}/kud/deployment_infra/installers/entrypoint-qat-driver-installer.sh | awk '/QAT_DRIVER_VERSION/ {print; exit}')
180     echo ${QAT_DRIVER_VERSION}
181 }
182
183 function compute_cluster_addons {
184     cat <<EOF
185 |Containerized Data Importer|https://github.com/kubevirt/containerized-data-importer|${CDI_VERSION}|Apache-2.0|
186 |cert-manager|https://cert-manager.io/|${CERT_MANAGER_VERSION}|Apache-2.0|
187 |CPU Manager for Kubernetes|https://github.com/intel/CPU-Manager-for-Kubernetes|${CPU_MANAGER_VERSION}|Apache-2.0|
188 |EMCO|https://gitlab.com/project-emco|$(git_repository_tag ${ICNDIR}/deploy/site/cluster-emco-management/emco-source.yaml | tr -d '"')|Apache-2.0|
189 |Flux|https://fluxcd.io/|${FLUX_VERSION}|Apache-2.0|
190 |Intel Network Adapter Linux Virtual Function Driver for Intel Ethernet Controller 700 and E810 Series|https://www.intel.com/content/www/us/en/download/18159/intel-network-adapter-linux-virtual-function-driver-for-intel-ethernet-controller-700-and-e810-series.html|$(iavf_driver_version)|GPL-2.0|
191 |Intel Network Adapter Virtual Function Driver Installer|https://gerrit.onap.org/r/#/admin/projects/multicloud/k8s|$(image_tag ${ICNDIR}/deploy/iavf-driver-installer/icn/daemonset.yaml iavf-driver-installer)|Apache-2.0|
192 |Istio|https://istio.io/|$(git_repository_tag ${ICNDIR}/deploy/site/cluster-addons/istio-source.yaml)|Apache-2.0|
193 |Kata Containers|https://katacontainers.io/|${KATA_VERSION}|Apache-2.0|
194 |KubeVirt|https://kubevirt.io/|${KUBEVIRT_VERSION}|Apache-2.0|
195 |Multus|https://github.com/k8snetworkplumbingwg/multus-cni|${MULTUS_VERSION}|Apache-2.0|
196 |Node Feature Discovery|https://github.com/kubernetes-sigs/node-feature-discovery|$(ref_tag ${ICNDIR}/deploy/node-feature-discovery/icn/kustomization.yaml)|Apache-2.0|
197 |Nodus|https://gerrit.akraino.org/r/admin/repos/icn/nodus|${NODUS_VERSION}|Apache-2.0|
198 |Intel QAT Driver for Linux for Intel Server Boards and Systems Based on Intel 62X Chipset|https://www.intel.com/content/www/us/en/download/19081/intel-quickassist-technology-intel-qat-driver-for-linux-for-intel-server-boards-and-systems-based-on-intel-62x-chipset.html|$(qat_driver_version)|GPL-2.0,BSD,OpenSSL,ZLib|
199 |Intel QAT Device Plugin|https://github.com/intel/intel-device-plugins-for-kubernetes|${QAT_VERSION}|Apache-2.0|
200 |Intel QAT Driver Installer|https://gerrit.onap.org/r/#/admin/projects/multicloud/k8s|$(image_tag ${ICNDIR}/deploy/qat-driver-installer/icn/daemonset.yaml qat-driver-installer)|Apache-2.0|
201 |SR-IOV Network Operator|https://github.com/k8snetworkplumbingwg/sriov-network-operator|$(git_repository_tag ${ICNDIR}/deploy/sriov-network-operator/icn/source.yaml)|Apache-2.0|
202 EOF
203 }
204
205 function compute_cluster {
206     table_header
207     compute_cluster_os
208     compute_cluster_k8s
209     compute_cluster_cri
210     compute_cluster_cni
211     compute_cluster_addons
212 }
213
214 function from_source {
215     cat <<EOF >${ICNDIR}/doc/software-bom.md
216 <!-- Markdown generated from tools/software-bom.sh. DO NOT EDIT. -->
217
218 # Software BOM
219
220 ## Jump server
221
222 $(jump_server)
223
224 ## Compute cluster
225
226 $(compute_cluster)
227
228 EOF
229 }
230
231 function from_installed {
232     cat <<EOF
233 <!-- Markdown generated from tools/software-bom.sh. DO NOT EDIT. -->
234
235 # Software BOM
236
237 ## Jump server
238
239 $(jump_server_installed)
240
241 EOF
242 }
243
244 case $1 in
245     "from-source") from_source ;;
246     "from-installed") from_installed ;;
247     *) cat <<EOF
248 Usage: $(basename $0) COMMAND
249
250 Commands:
251   from-source        - Software BOM of ICN source repository
252   from-installed     - Software BOM of installed components
253 EOF
254        ;;
255 esac