Olaf Bohlen
2023-02-27 586b0804a6b881fed73ee1d7be571728cfef5de0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
#+TODO: TODO(t) NEXT(n) WAITING(w) SOMEDAY(s) DELEGATED(g) PROJ(p) PLANNED(l) | DONE(d) FORWARDED(f) CANCELLED(c)
#+PRIORITIES: A D D
#+OPTIONS: H:1 author:nil toc:nil date:nil t:nil <:t e:t p:t num:nil
#+TITLE: OpenShift Diagrams by Olaf Bohlen
#+LaTeX_CLASS: article
#+LaTeX_HEADER: \usepackage[ttscale=.875]{libertine}
#+LaTeX_HEADER: \usepackage{sectsty}
#+LaTeX_HEADER: \sectionfont{\normalfont\scshape}
#+LaTeX_HEADER: \subsectionfont{\normalfont\itshape}
#+LATEX_HEADER: \renewcommand\maketitle{}
 
* Deployment on OpenShift with images using Kubernetes Deployments
 
#+BEGIN_SRC ditaa :file ocp-dep-image1.png :cmdline -r
oc new-app sample.registry.org/user/image:tag
   |
   |                             
   | (1)  +-------------+   points to    +------------------------------------+
   +--->  | ImageStream |  ----------->  | external Registry cRED {s}         |
   |      | (IS)        |                | sample.registry.org/user/image:tag |
   |      +-------------+                +------------------------------------+
   |             ^
   |             | points to
   | (2)  +------------------+  (5) creates                       +-----------------------+
   +--->  | Deployment       | -------------------------------->  | ReplicaSet            |                
   |      |                  |  (4)                               |                       |
   |      |                  | -------------------+               +-----------------------+
   |      +------------------+  creates           |                       |
   |                                              |                       |scales &
   |                                              v                       |monitors
   | (3)  +---------+   load balances   +----------------+                |
   +--->  | Service |  -------------->  | ApplicationPod |  <-------------+
          | (SVC)   |                   |                |
          +---------+                   +----------------+
#+END_SRC
 
* Deployment on OpenShift with images using OpenShift DeploymentConfigs (dc)
 
#+BEGIN_SRC ditaa :file ocp-dep-image2.png :cmdline -r
oc new-app sample.registry.org/user/image:tag
   |
   |                             
   | (1)  +-------------+   points to    +------------------------------------+
   +--->  | ImageStream |  ----------->  | external Registry cRED {s}         |
   |      | (IS)        |                | sample.registry.org/user/image:tag |
   |      +-------------+                +------------------------------------+
   |             ^
   |             | points to
   | (2)  +------------------+  (5) creates                       +-----------------------+
   +--->  | DeploymentConfig | -------------------------------->  | ReplicationController |                
   |      | (DC)             |  (4)         +-----------+         | (RC)                  |
   |      |                  | --------->   | DeployPod |         +-----------------------+
   |      +------------------+  creates     +-----------+                 |
   |                                              | (6) creates           |scales &
   |                                              v                       |monitors
   | (3)  +---------+   load balances   +----------------+                |
   +--->  | Service |  -------------->  | ApplicationPod |  <-------------+
          | (SVC)   |                   |                |
          +---------+                   +----------------+
#+END_SRC
 
#+results:
[[file:ocp-dep-image1.png]]
 
* Deployment on OpenShift with Source-to-Image (S2I) using Kubernetes Deployments
 
#+BEGIN_SRC ditaa :file ocp-dep-s2i1.png :cmdline -rE
oc new-app http://git.repo-server.org/sampleapp
       |
       |                             
       | (1)  +-------------+   points to    +----------------------------+    +------------------------------------+
       +--->  | ImageStream |  ----------->  | internal Registry cBLU {s} |    | external Registry cRED {s}         |
       |      | (IS)        |<+              | sampleapp:latest           |    | sample.registry.org/ose/s2ibuilder |
       |      +-------------+ |              +----------------------------+    +------------------------------------+
       |                      |                  ^                                      ^
       |                      |                  | (9) docker commits                   | points to
       |                      |                  |                                      |
       | (2)  +-------------+ |(5) creates   +--------------+  (6) docker run      +-----------------+
       +--->  | BuildConfig | |----------->  | BuilderPod   | ------------------>  | S2I ImageStream |
       |      | (BC)        | |              | (8) assemble |                      | (IS)            |
       |      +-------------+ |              +--------------+                      +-----------------+
       |             |        |                  | (7) git clone                        ^
       |             +--=-----|----=-------------|---=----------------------------------+
       |       ImageChange    |                  |                                                                   
       |       Trigger watches|                  v                                                                    
       |       S2I IS         |              +--------------------------------------+                                
       |                      |              | git Repository {s}                   |                                
build  |                      |              | http://git.repo-server.org/sampleapp |                                
step   |                      :              +--------------------------------------+                                
-=-----|-=--------------------|--=-------------------------------------------------------------------------------------
deploy |                      |ImageChange
step   |                      |Trigger
       |                      |watches IS 
       | (3)  +------------------+  (11) creates                      +-----------------------+
       +--->  | Deployment       | -------------------------------->  | ReplicaSet            |                
       |      |                  |  (10)                              |                       |
       |      |                  | -------------------+               +-----------------------+
       |      +------------------+  creates           |                       |
       |                                              |                       |scales &
       |                                              v                       |monitors
       | (4)  +---------+   load balances   +----------------+                |
       +--->  | Service |  -------------->  | ApplicationPod |  <-------------+
              | (SVC)   |                   |                |
              +---------+                   +----------------+
#+END_SRC
 
 
* Deployment on OpenShift with Source-to-Image (S2I) using DeploymentConfigs (dc)
 
#+BEGIN_SRC ditaa :file ocp-dep-s2i2.png :cmdline -rE
oc new-app http://git.repo-server.org/sampleapp
       |
       |                             
       | (1)  +-------------+   points to    +----------------------------+    +------------------------------------+
       +--->  | ImageStream |  ----------->  | internal Registry cBLU {s} |    | external Registry cRED {s}         |
       |      | (IS)        |<+              | sampleapp:latest           |    | sample.registry.org/ose/s2ibuilder |
       |      +-------------+ |              +----------------------------+    +------------------------------------+
       |                      |                  ^                                      ^
       |                      |                  | (9) docker commits                   | points to
       |                      |                  |                                      |
       | (2)  +-------------+ |(5) creates   +--------------+  (6) docker run      +-----------------+
       +--->  | BuildConfig | |----------->  | BuilderPod   | ------------------>  | S2I ImageStream |
       |      | (BC)        | |              | (8) assemble |                      | (IS)            |
       |      +-------------+ |              +--------------+                      +-----------------+
       |             |        |                  | (7) git clone                        ^
       |             +--=-----|----=-------------|---=----------------------------------+
       |       ImageChange    |                  |                                                                   
       |       Trigger watches|                  v                                                                    
       |       S2I IS         |              +--------------------------------------+                                
       |                      |              | git Repository {s}                   |                                
build  |                      |              | http://git.repo-server.org/sampleapp |                                
step   |                      :              +--------------------------------------+                                
-=-----|-=--------------------|--=-------------------------------------------------------------------------------------
deploy |                      |ImageChange
step   |                      |Trigger
       |                      |watches IS 
       | (3)  +------------------+  (11) creates                      +-----------------------+
       +--->  | DeploymentConfig | -------------------------------->  | ReplicationController |                
       |      | (DC)             |  (10)        +-----------+         | (RC)                  |
       |      |                  | --------->   | DeployPod |         +-----------------------+
       |      +------------------+  creates     +-----------+                 |
       |                                              | (12) creates          |scales &
       |                                              v                       |monitors
       | (4)  +---------+   load balances   +----------------+                |
       +--->  | Service |  -------------->  | ApplicationPod |  <-------------+
              | (SVC)   |                   |                |
              +---------+                   +----------------+
#+END_SRC
 
#+results:
[[file:ocp-dep-s2i1.png]]
 
* Input Detection OpenShift 
#+begin_src plantuml :file openshift-input-detection.png
!pragma useVerticalIf on
:oc new-app <input spec>;
if (docker pull) then (yes)
  -> yes
  --docker-image= forces this;
  :docker run;
  note: --docker-image= forces this
  stop
else (no)
  :try for an SCM code repo;
  note: --code forces this
if (git clone) then (no)
  :abort with error;
  stop
elseif (Dockerfile found?) then (yes)
  :docker build;
  note: --strategy=docker forces this
  :docker run;
  stop
else (no)
  :continue with S2I;
  note right: --strategy=source forces this
if (pom.xml found?) then (yes)
  :search for JEE S2I builder;
  note: use -i to suggest an S2I image stream (tag);
  :continue with S2I process;
  stop
elseif (index.php found?) then (yes)
  :search for PHP S2I builder;
  note 
    prefix the git url with builderis~ (tilda!) 
    to turn off language detection and force this builder
  end note
  :continue with S2I process;
  stop
else
  :abort with error;
  stop
endif
#+end_src
 
#+results:
[[file:openshift-input-detection.png]]