You can purchase an under the mattress railing. Part of the railing is tucked under the mattress & the weight of the person in the bunk will keep it in place. They are extendable & will fit up to a super twin sized mattress. The railing can be folded up & stored under the mattress when not in use. They're typically sold on Amazon or you can get one at a mattress store.
You can also get a ladder on Amazon.
It ain't easy being me...I've tried.