Ionic bonds are formed as one atom the metal gives up or transfers one of its valence electron to the other atom that would then be able to accept it. This other atom is a non metal. This process occurs because the atoms want to become more stable by each of them satisfying the octet rule. In which atoms would have a maximum of 8 valence electrons.