Skip to content

Commit eb7d057

Browse files
MiltonMilton
authored andcommitted
feat: added new question
1 parent 6908960 commit eb7d057

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

main.go

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ func main() {
6868
createRoleOne(clientset),
6969
createJob(clientset),
7070
createCronjob(clientset),
71+
createStateFulSet(clientset),
7172
}
7273

7374
renderResultsTable(results)
@@ -843,10 +844,42 @@ func createCronjob(clientset *kubernetes.Clientset) Result {
843844
}
844845
}
845846

847+
func createStateFulSet(clientset *kubernetes.Clientset) Result {
848+
const (
849+
expectedNamespace = "default"
850+
expectedName = "statefulset-gain"
851+
expectedImage = "busybox:1.28"
852+
expectedCommand = "sleep 3600"
853+
expectedReplicas = int32(3)
854+
)
855+
856+
statefulset, err := clientset.AppsV1().StatefulSets(expectedNamespace).Get(context.TODO(), expectedName, metav1.GetOptions{})
857+
858+
if err != nil {
859+
return Result{
860+
TestName: "Question 26 - Create a statefulset statefulset-gain with image busybox:1.28, command 'sleep 3600' and replicas 3",
861+
Passed: false,
862+
Difficulty: "Medium",
863+
}
864+
}
865+
866+
passed := err == nil &&
867+
expectedName == statefulset.Name &&
868+
expectedImage == statefulset.Spec.Template.Spec.Containers[0].Image &&
869+
expectedCommand == statefulset.Spec.Template.Spec.Containers[0].Command[0] &&
870+
expectedReplicas == statefulset.Status.ReadyReplicas
871+
872+
return Result{
873+
TestName: "Question 26 - Create a statefulset statefulset-gain with image busybox:1.28, command 'sleep 3600' and replicas 3",
874+
Passed: passed,
875+
Difficulty: "Medium",
876+
}
877+
}
878+
846879
// render table of results
847880
func renderResultsTable(results []Result) {
848881
table := tablewriter.NewWriter(os.Stdout)
849-
table.SetHeader([]string{"KubeLearn - Test your knowledge of Kubernetes v0.1.7", "Result", "Difficulty"})
882+
table.SetHeader([]string{"KubeLearn - Test your knowledge of Kubernetes v0.1.8", "Result", "Difficulty"})
850883
table.SetAutoWrapText(false)
851884

852885
for _, result := range results {

0 commit comments

Comments
 (0)