@@ -53,6 +53,177 @@ public function addPort(int $containerPort, string $protocol = 'TCP', string $na
53
53
return $ this ->setAttribute ('ports ' , $ ports );
54
54
}
55
55
56
+ /**
57
+ * Requests minimum memory for the container.
58
+ *
59
+ * @param int $size
60
+ * @param string $measure
61
+ * @return $this
62
+ */
63
+ public function minMemory (int $ size , string $ measure = 'Gi ' )
64
+ {
65
+ return $ this ->setAttribute ('resources.requests.memory ' , $ size .$ measure );
66
+ }
67
+
68
+ /**
69
+ * Get the minimum memory amount.
70
+ *
71
+ * @return string|null
72
+ */
73
+ public function getMinMemory ()
74
+ {
75
+ return $ this ->getAttribute ('resources.requests.memory ' , null );
76
+ }
77
+
78
+ /**
79
+ * Requests minimum CPU for the container.
80
+ *
81
+ * @param string $size
82
+ * @return $this
83
+ */
84
+ public function minCpu (string $ size )
85
+ {
86
+ return $ this ->setAttribute ('resources.requests.cpu ' , $ size );
87
+ }
88
+
89
+ /**
90
+ * Get the minimum CPU amount.
91
+ *
92
+ * @return string|null
93
+ */
94
+ public function getMinCpu ()
95
+ {
96
+ return $ this ->getAttribute ('resources.requests.cpu ' , null );
97
+ }
98
+
99
+ /**
100
+ * Sets max memory for the container.
101
+ *
102
+ * @param int $size
103
+ * @param string $measure
104
+ * @return $this
105
+ */
106
+ public function maxMemory (int $ size , string $ measure = 'Gi ' )
107
+ {
108
+ return $ this ->setAttribute ('resources.limits.memory ' , $ size .$ measure );
109
+ }
110
+
111
+ /**
112
+ * Get the max memory amount.
113
+ *
114
+ * @return string|null
115
+ */
116
+ public function getMaxMemory ()
117
+ {
118
+ return $ this ->getAttribute ('resources.limits.memory ' , null );
119
+ }
120
+
121
+ /**
122
+ * Sets max CPU for the container.
123
+ *
124
+ * @param string $size
125
+ * @return $this
126
+ */
127
+ public function maxCpu (string $ size )
128
+ {
129
+ return $ this ->setAttribute ('resources.limits.cpu ' , $ size );
130
+ }
131
+
132
+ /**
133
+ * Get the max CPU amount.
134
+ *
135
+ * @return string|null
136
+ */
137
+ public function getMaxCpu ()
138
+ {
139
+ return $ this ->getAttribute ('resources.limits.cpu ' , null );
140
+ }
141
+
142
+
143
+ /**
144
+ * Set the readiness probe for the container.
145
+ *
146
+ * @param \RenokiCo\PhpK8s\Instances\Probe $probe
147
+ * @return $this
148
+ */
149
+ public function setReadinessProbe (Probe $ probe )
150
+ {
151
+ return $ this ->setAttribute ('readinessProbe ' , $ probe ->toArray ());
152
+ }
153
+
154
+ /**
155
+ * Get the readiness probe.
156
+ *
157
+ * @param bool $asInstance
158
+ * @return null|array|\RenokiCo\PhpK8s\Instances\Probe
159
+ */
160
+ public function getReadinessProbe (bool $ asInstance = true )
161
+ {
162
+ $ probe = $ this ->getAttribute ('readinessProbe ' , null );
163
+
164
+ if (! $ probe ) {
165
+ return ;
166
+ }
167
+
168
+ return $ asInstance ? new Probe ($ probe ) : $ probe ;
169
+ }
170
+
171
+ /**
172
+ * Set the liveness probe for the container.
173
+ *
174
+ * @param \RenokiCo\PhpK8s\Instances\Probe $probe
175
+ * @return $this
176
+ */
177
+ public function setLivenessProbe (Probe $ probe )
178
+ {
179
+ return $ this ->setAttribute ('livenessProbe ' , $ probe ->toArray ());
180
+ }
181
+
182
+ /**
183
+ * Get the liveness probe.
184
+ *
185
+ * @param bool $asInstance
186
+ * @return null|array|\RenokiCo\PhpK8s\Instances\Probe
187
+ */
188
+ public function getLivenessProbe (bool $ asInstance = true )
189
+ {
190
+ $ probe = $ this ->getAttribute ('livenessProbe ' , null );
191
+
192
+ if (! $ probe ) {
193
+ return ;
194
+ }
195
+
196
+ return $ asInstance ? new Probe ($ probe ) : $ probe ;
197
+ }
198
+
199
+ /**
200
+ * Set the startup probe for the container.
201
+ *
202
+ * @param \RenokiCo\PhpK8s\Instances\Probe $probe
203
+ * @return $this
204
+ */
205
+ public function setStartupProbe (Probe $ probe )
206
+ {
207
+ return $ this ->setAttribute ('startupProbe ' , $ probe ->toArray ());
208
+ }
209
+
210
+ /**
211
+ * Get the startup probe.
212
+ *
213
+ * @param bool $asInstance
214
+ * @return null|array|\RenokiCo\PhpK8s\Instances\Probe
215
+ */
216
+ public function getStartupProbe (bool $ asInstance = true )
217
+ {
218
+ $ probe = $ this ->getAttribute ('startupProbe ' , null );
219
+
220
+ if (! $ probe ) {
221
+ return ;
222
+ }
223
+
224
+ return $ asInstance ? new Probe ($ probe ) : $ probe ;
225
+ }
226
+
56
227
/**
57
228
* Check if the container is ready.
58
229
*
0 commit comments