Extend K8S and RIC installation instructions
[it/dep.git] / ric-common / Common-Template / helm / ric-common / templates / _dockerregistry.tpl
1 ################################################################################
2 #   Copyright (c) 2019 AT&T Intellectual Property.                             #
3 #   Copyright (c) 2019 Nokia.                                                  #
4 #                                                                              #
5 #   Licensed under the Apache License, Version 2.0 (the "License");            #
6 #   you may not use this file except in compliance with the License.           #
7 #   You may obtain a copy of the License at                                    #
8 #                                                                              #
9 #       http://www.apache.org/licenses/LICENSE-2.0                             #
10 #                                                                              #
11 #   Unless required by applicable law or agreed to in writing, software        #
12 #   distributed under the License is distributed on an "AS IS" BASIS,          #
13 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
14 #   See the License for the specific language governing permissions and        #
15 #   limitations under the License.                                             #
16 ################################################################################
17
18 {{/*
19   Resolve the name of the common image repository.
20   The value for .Values.repository is used by default,
21   unless either override mechanism is used.
22
23   - .Values.global.repository  : override default image repository for all images
24   - .Values.repositoryOverride : override global and default image repository on a per image basis
25 */}}
26 {{- define "common.repository" -}}
27   {{- $componentname := .Chart.Name -}}
28   {{- $firsttier := (index .Values (printf "%s" $componentname)) -}}
29   {{- if $firsttier -}}
30     {{- $secondtier := (index .Values (printf "%s" $componentname) (printf "%s" "repositoryOverride")) -}}
31     {{- if $secondtier -}}
32       {{- printf "%s" $secondtier -}}
33     {{- else -}}
34       {{- if .Values.global -}}
35         {{- if .Values.global.repository -}}
36           {{- printf "%s" .Values.global.repository -}}
37         {{- else -}}
38           {{- printf "%s" .Values.repository -}}
39         {{- end -}}
40       {{- else -}}
41         {{- printf "%s" .Values.repository -}}
42       {{- end -}}  
43     {{- end -}}
44   {{- else -}}
45     {{- if .Values.global -}}
46       {{- if .Values.global.repository -}}
47         {{- printf "%s" .Values.global.repository -}}
48       {{- else -}}
49         {{- printf "%s" .Values.repository -}}
50       {{- end -}}
51     {{- else -}}
52       {{- printf "%s" .Values.repository -}}
53     {{- end -}}  
54   {{- end -}}
55 {{- end -}}
56
57
58 {{/*
59   Resolve the docker image repository secret token configmap.
60   The secret token should be installed by K8S system admin.
61   The value for .Values.repositoryCred is used by default,
62   unless either override mechanism is used.
63
64   - .Values.global.repositoryCred  : override default docker registry credential
65   - .Values.repositoryCredOverride : override global and default docker registry credential
66 */}}
67 {{- define "common.repositoryCred" -}}
68   {{- $componentname := .Chart.Name -}}
69   {{- $firsttier := (index .Values (printf "%s" $componentname)) -}}
70   {{- if $firsttier -}}
71     {{- $secondtier := (index .Values (printf "%s" $componentname) (printf "%s" "repositoryCredOverride")) -}}
72     {{- if $secondtier -}}
73       {{- printf "%s" $secondtier -}}
74     {{- else -}}
75       {{- if .Values.global -}}
76         {{- if .Values.global.repositoryCred -}}
77           {{- printf "%s" .Values.global.repositoryCred -}}
78         {{- else -}}
79           {{- printf "%s" .Values.repositoryCred -}}
80         {{- end -}}
81       {{- else -}}
82         {{- printf "%s" .Values.repositoryCred -}}
83       {{- end -}}
84     {{- end -}}
85   {{- else -}}
86     {{- if .Values.global -}}
87       {{- if .Values.global.repositoryCred -}}
88         {{- printf "%s" .Values.global.repositoryCred -}}
89       {{- else -}}
90         {{- printf "%s" .Values.repositoryCred -}}
91       {{- end -}}
92     {{- else -}}
93       {{- printf "%s" .Values.repositoryCred -}}
94     {{- end -}}
95   {{- end -}}
96 {{- end -}}
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111 {{/*
112   Define the golbal image pull policy.
113   The value for .Values.imagePullPolicy is used by default,
114   unless either override mechanism is used.
115
116   - .Values.global.imagePullPolicy  : override default pull policy
117   - .Values.imagePullPolicyOverride : override global and default pull policy
118 */}}
119 {{- define "common.pullPolicy" -}}
120   {{- if .Values.imagePullPolicyOverride -}}
121     {{- printf "%s" .Values.imagePullPolicyOverride -}}
122   {{- else -}}
123     {{- if  .Values.global -}}
124       {{- if .Values.global.imagePullPolicy -}}
125         {{- printf "%s" .Values.global.imagePullPolicy -}}
126       {{- else -}}
127         {{- printf "%s" .Values.imagePullPolicy -}}
128       {{- end -}}
129     {{- else -}}
130       {{- printf "%s" .Values.imagePullPolicy -}}
131     {{- end -}}
132   {{- end -}}
133 {{- end -}}
134
135
136 {{/*
137   Resolve the docker registry certificate name.
138   The value for .Values.repositoryCert is used by default,
139   unless either override mechanism is used.
140
141   - .Values.global.repositoryCert  : override default repository certificate
142   - .Values.repositoryCertOverride : override global and default repository certificate
143 */}}
144 {{- define "common.repositorycert" -}}
145   {{- if .Values.repositoryCertOverride -}}
146     {{- printf "%s" .Values.repositoryCertOverride -}}
147   {{- else -}}
148     {{- if  .Values.global -}}
149       {{- if .Values.global.repositoryCert -}}
150         {{- printf "%s" .Values.global.repositoryCert -}}
151       {{- else -}}
152         {{- printf "%s" .Values.repositoryCert -}}
153       {{- end -}}
154     {{- else -}}
155       {{- printf "%s" .Values.repositoryCert -}}
156     {{- end -}}
157   {{- end -}}
158 {{- end -}}
159
160
161
162
163
164
165 {{/*
166 Generate certificates for the docker registry
167 */}}
168 {{- define "common.repository.gen-certs" -}}
169 {{- $altNames := list ( printf "docker.%s" .Values.ingress.hostpostfix ) -}}
170 {{- $ca := genCA "docker-registry-ca" 365 -}}
171 {{- $cert := genSignedCert ( include "nexus.name" . ) nil $altNames 365 $ca -}}
172 tls.crt: {{ $cert.Cert | b64enc }}
173 tls.key: {{ $cert.Key | b64enc }}
174 {{- end -}}